<%@ page language="java" contentType="text/html; charset=UTF-8"
 	pageEncoding="UTF-8"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<base href="<%=basePath%>">


<link rel="stylesheet" type="text/css" href="static/js/jquery-easyui-1.5.3/themes/default/easyui.css"/>
<link rel="stylesheet" type="text/css" href="static/js/jquery-easyui-1.5.3/themes/icon.css"/>
<script type="text/javascript" src="static/js/jquery-easyui-1.5.3/jquery.min.js"></script>

<script type="text/javascript" src="static/js/jquery-easyui-1.5.3/jquery.easyui.min.js"></script>
<script type="text/javascript" src="static/js/jquery-easyui-1.5.3/locale/easyui-lang-zh_CN.js"></script>
<script language="javascript" type="text/javascript"src="static/js/My97DatePicker/WdatePicker.js?new Date()"></script>
<script type="text/javascript" src="static/js/consignhandle/checkBox.js"></script>
<script type="text/javascript"src="static/js/common/tooltip.js"></script>
<title>外贸出口托单录入</title>
<style type="text/css">
	.validatebox-text{width:50px;}
	#volume{width:90px;}
	*[disabled]{background: #D3E0EC;color:#000;}
	select{border:none;border:1px solid #95B8E7;}
	input[type=text],select{border-radius:2px;}
</style>
</head>
<body>
	<form id="form1" name="form1" method="post">
        <input id="businessType" name="businessType" type="hidden" value="${pd.businessType}">
        <div style="width:100%;border-bottom:1px solid #000000;">
            <table style="width:100%;">
                <tr>
                    <td style="width:12%;text-align:right;">
                     	 销售人员<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="text" name="salesManName" id="salesManName">
                    </td>
                    <td style="width:12%;text-align:right;">
                       	 所属部门<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="hidden" name="salesManDep" id="salesManDep"/>
                        <input type="text" name="salesManDepShow" id="salesManDepShow" disabled="disabled"/>
                        <input type="hidden" name="tradeFlag" id="tradeFlag" value="2"/>
                    </td>
                    <td style="width:12%;text-align:right;">
                      	  所属区域<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="hidden" id="salesManAgent" name="salesManAgent">
                        <input type="text" id="salesManAgentShow" name="salesManAgentShow" disabled="disabled">
                    </td>
                </tr>
                <tr id="tr1" style="display:none">
                	<td style="width:12%;text-align:right;">
                    	<span id="s1" style="display:none;">
                        	第二销售人员<font color="#FF0000">*</font>
                        </span>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <div style="display:none" id="div1">
                        	<input type="text" id="secondSalesMan" name="secondSalesMan">
                        </div>
                    </td>
                     <td style="width:12%;text-align:right;">
                     	<div style="display:none" id="d1">
                    		所属部门<font color="#FF0000">*</font>
                    	</div>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                   		<div style="display:none" id="d2">
                        	<input type="hidden" name="secondSalesManDep" id="secondSalesManDep"/>
                        	<input type="text" name="secondSalesManDepShow" id="secondSalesManDepShow" disabled="disabled"/>
                        </div>
                    </td>
                    <td style="width:12%;text-align:right;">
                    	所属区域<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="hidden" id="secondSalesAgent" name="secondSalesAgent">
                        <input type="text" id="secondSalesAgentShow" name="secondSalesAgentShow" disabled="disabled">
                    </td>
                    
                </tr>
                <tr>
                    <td style="width:12%;text-align:right;">
                    	&nbsp;
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<select id="isHBL" name="isHBL">
							<option value="不发HBL">不发HBL</option>
							<option value="船公司发HBL">船公司发HBL</option>
							<option value="自己发HBL">自己发HBL</option>
						</select>
                    
                    	<input type="checkbox" id="isTaoyue" name="isTaoyue" value="y">
                        <label for="isTaoyue" id="taoyuel">是否套约</label>
                    </td>
                    <td style="width:12%;text-align:right;">
                    	托运人全称<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="text" name="agencyMan" id="agencyMan"/>
                    </td>
                    <td style="width:12%;text-align:right;">
                    	货主<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="text" name="agencyContact" id="agencyContact"/>
                    </td>
                </tr>
                <tr>
                    <td style="width:12%;text-align:right;">
                    	托运人自编号<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="text" name="agencySelfNo" id="agencySelfNo"/>
                    </td>
                    <td style="width:12%;text-align:right;">
                    	托运人联系人<font color="#FFFFFF">*</font>
                    </td>
                	<td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="text" name="contact" id="contact"/>
                    </td>
                    <td style="width:12%;text-align:right;">
                    	付款方式<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="text" id="payWay" name="payWay" readonly="readonly"/>
                    </td>
                </tr>
                <tr>
                	<td style="width:12%;text-align:right;">
                    	客户类别<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="text" id="clientType" name="clientType" readonly="readonly"/>
                    </td>
                	<td style="width:12%;text-align:right;">
                    	托运人联系方式<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="text" name="contactInfo" id="contactInfo"/>
                    </td>
                    <td style="width:12%;text-align:right;">
                    	箱主<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="boxMaster" name="boxMaster">
                    </td>
                </tr>
                <tr id="tr2" style="display:none">
                	<td style="width:12%;text-align:right;">
                    	&nbsp;
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="checkbox" id="isFeeCUC" name="isFeeCUC" value="0">
                        <label for="isFeeCUC">是否减免CUC</label>
                    </td>
                	<td style="width:12%;text-align:right;">
                    	收货人MSC-CODE<font color="#FFFFFF">*</font>
                    </td>
                	<td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="text" name="consigneeMscCode" id="consigneeMscCode"/>
                    </td>
                    <td style="width:12%;text-align:right;">
                    	通知人MSC-CODE<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="text" name="notifierMscCode" id="notifierMscCode"/>
                    </td>
                </tr>
                <tr>
                	<td style="width:12%;text-align:right;">
                    	发票号<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="text" name="invoiceNo" id="invoiceNo"/>
                    </td>
                    <td style="width:12%;text-align:right;">
                    	货源<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="text" name="supplyOfGoods" id="supplyOfGoods"/>
                    </td>
                     <td style="width:12%;text-align:right;">
                    	货代客服<font color="#FF0000"></font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="forwarder_man" name="forwarder_man">
                    </td>
                </tr>
            </table>
        </div>
        <div style="width:100%;border-bottom:1px solid #000000;">
        	<div style="text-align:center;width:100%;height:10px;"></div>
            <table style="width:100%;">
            	<tr>
                	<td style="width:12%;text-align:right;">
                    	发货人(SHIPPER)<font color="#FF0000">*</font><br>
                    	<input type="text" id="searchShipper" name="searchShipper">
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;" colspan="2">
                    	<textarea style="width:300px;height:150px;ime-mode:disabled;" id="shipper" name="shipper" onblur="checkInput(this.id,'发货人')" onkeyup="this.value = this.value.toUpperCase();"></textarea>
                    </td>
                     <td style="width:12%;text-align:right;">
                    	海船公司订舱<br>注意事项<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;" colspan="2">
                    	<textarea style="width:300px;height:150px;" id="boxMasterRemark" name="boxMasterRemark" readonly="readonly" onkeyup="this.value = this.value.toUpperCase();"></textarea>
                    </td>
                </tr>
                <tr>
                	<td style="width:12%;text-align:right;">
                    	收货人(CONSIGNEE)<font color="#FF0000">*</font><br>
                    	<input type="text" id="searchConsignee" name="searchConsignee">
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;" colspan="2">
                    	<textarea style="width:300px;height:150px;ime-mode:disabled;" id="consignee" name="consignee" onblur="checkInput(this.id,'收货人')" onkeyup="this.value = this.value.toUpperCase();" ></textarea>
                    </td>
                    <td style="width:12%;text-align:right;">
                    	装运唛头(MARK)<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;" colspan="2">
                    	<textarea style="width:300px;height:150px;ime-mode:disabled;" id="goodsSign" name="goodsSign" onblur="checkInput(this.id,'装运唛头')" onkeyup="this.value = this.value.toUpperCase();">N/M</textarea>
                    </td>
                </tr>
                <tr>
                	<td style="width:12%;text-align:right;">
                    	通知人(NOTIFY)<font color="#FF0000">*</font><br>
                    	<input type="text" id="searchNoticeMan" name="searchNoticeMan">
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;" colspan="2">
                    	<textarea style="width:300px;height:150px;ime-mode:disabled" id="noticeMan" name="noticeMan" onblur="checkInput(this.id,'通知人')" onkeyup="this.value = this.value.toUpperCase();"></textarea>
                    </td>
                    <td style="width:12%;text-align:right;">
                    	货物描述(DESCRIPTION)<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;" colspan="2">
                    	<textarea style="width:300px;height:150px;ime-mode:disabled" id="goodsEnglishName" name="goodsEnglishName" onblur="checkInput(this.id,'货物描述')" onkeyup="this.value = this.value.toUpperCase();"></textarea>
                    </td>
                </tr>
                <tr>
                	<td style="width:12%;text-align:right;">
                    	贸易方式<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<select id="tradeMode" name="tradeMode" style="width:200px;border:1px solid #95B8E7">
                    		<option value=""> </option>
                    		<option value="FOB">FOB</option>
                    		<option value="CIF">CIF</option>
                    		<option value="CFR">CFR</option>
                    	</select>
                    </td>
                    <td style="width:12%;text-align:right;">
                    	可否分批<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="partialFlag" name="partialFlag">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	可否转船<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="changeShipFlag" name="changeShipFlag">
                    </td>
                </tr>
            	<tr>
                	<td style="width:12%;text-align:right;">
                    	Port Of Loading<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="portOfLoading" name="portOfLoading">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	Port Of Discharge<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="portOfDischarge" name="portOfDischarge">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	Place Of Delivery<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="placeOfDelivery" name="placeOfDelivery">
                    </td>
                </tr>
                <tr>
                	<td style="width:12%;text-align:right;">
						江船起运港区<font color="#FF0000">*</font>
                   </td>
                   <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="loadHarbour" name="loadHarbour">
                   </td>
                   <td style="width:12%;text-align:right;">
						目的地国家<font color="#FF0000">*</font>
                   </td>
                   <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="stopCountry" name="stopCountry">
                   </td>
                   <td style="width:12%;text-align:right;">
                    	境内货源地<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="goodsSource" name="goodsSource">
                    </td>
                </tr>
            	<tr>
                	<td style="width:12%;text-align:right;">
                    	中文品名<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="goodsChineseName" name="goodsChineseName" onblur="checkDangerous(this.value)">
                    </td>
                   <td style="width:12%;text-align:right;">
                    	HS CODE<font color="#FFFFFF" id="hsf">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="hsCode" name="hsCode">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	是否木质包装<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="woodenPacking" name="woodenPacking">
                    	<span id="span1" style="display:none;">
	                    	<input type="checkbox" id="hasIPPC" name="hasIPPC" value="y">
	                    	<label for="hasIPPC">有无IPPC</label>
                    	</span>
                    </td>
                </tr>
                <tr>
                	<td style="width:12%;text-align:right;">
                    	货物件数及单位<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="goodsPkgs" name="goodsPkgs" style="width:65px">
                    	<input type="text" id="goodsPackage" name="goodsPackage" style="width:125px">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	货物毛重<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="goodsWeight" name="goodsWeight" style="width:170px"> KGS
                    </td>
                	<td style="width:12%;text-align:right;">
                    	体积<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="goodsMeasurment" name="goodsMeasurment" style="width:170px"> CBM
                    </td>
                </tr>
               
                <tr>
                	<td style="width:12%;text-align:right;">
                    	提单类型<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="bolType" name="bolType">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	箱型确定<font color="#FF0000">*</font>
                    </td>
                    <td style="padding-left:10px;text-align:left;" colspan="3">
                    	<input type="text" id="boxType" name="boxType" style="width:97%" readonly="readonly">
                    	<input type="hidden" id="bigBox" name="bigBox" readonly="readonly">
                    	<input type="hidden" id="smallBox" name="smallBox" readonly="readonly">
                    	<input type="hidden" id="bigBoxH" name="bigBoxH" readonly="readonly">
                    	<input type="hidden" id="bigbigBox" name="bigbigBox" readonly="readonly">
                    	<input type="hidden" id="teu" name="teu" readonly="readonly">
                    	<input type="hidden" id="specialbox" name="specialbox" readonly="readonly">
                    </td>
                </tr>
                <tr>
                	<td style="width:12%;text-align:right;">
                    	是否指定用箱<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="specifiedBox" name="specifiedBox">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	<span id="s6">
                    		箱号<font color="#FFFFFF">*</font>
                    	</span>
                    </td>
                	<td style="padding-left:10px;text-align:left;" colspan="3">
                		<input type="text" id="boxNo" name="boxNo" style="width:97%;display:none" readonly="readonly">
                		<input type="hidden" id="hBoxType" name="hBoxType">
                	</td>
                </tr>
                <tr>
<!--                     <td  style="width:12%;text-align:right;"> -->
<!--                     	客户免堆期<font color="#FFFFFF">*</font> -->
<!--                     </td> -->
<!--                     <td   style="padding-left:10px;text-align:left;width:55%;" colspan="3"> -->
                    	
<!--                     	<input type="text" id="freeDayRemark" name="freeDayRemark"> -->
<!--                     </td> -->
                     <td  style="width:12%;text-align:right;">
                    	空重箱<font color="#FF0000">*</font>
                    </td>
                    <td  colspan="3" style="padding-left:10px;text-align:left;width:55%;" >                    	
                    	<input type="text" id="emptyweightbox" name="emptyweightbox">
                    </td>
                    
                    <td style="width:12%;text-align:right;">
                    	货物种类<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="goodsType" name="goodsType">
                    </td>
                </tr>
                <tr id="tr9" style="display:none">
                    <td style="width:12%;text-align:right;">
                    	<span id="s2" style="display:none">冷藏温度<font color="#FF0000">*</font></span>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<div style="display:none" id="div2">
                    		<input type="text" id="coldRem" name="coldRem">℃
                    	</div>
                    </td>
                	<td style="width:12%;text-align:right;">
                    	<span id="s3" style="display:none">危险品名<font color="#FF0000">*</font></span>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<div style="display:none" id="div3">
                    		<input type="text" id="dangerousName" name="dangerousName" style="display:none">
                    	</div>
                    </td>
                    <td style="width:12%;text-align:right;">
                    	<span id="s5" style="display:none">危险品类别<font color="#FF0000">*</font></span>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<div style="display:none" id="div7">
                    		<input type="text" id="dangerousType" name="dangerousType" readonly="readonly">
                    	</div>
                    </td>
                </tr>
                <tr id="tr8" style="display:none">
                	<td style="width:12%;text-align:right;">
                    	危险品等级<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="dangerousLevel" name="dangerousLevel"  readonly="readonly">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	国内代码<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="internalCode" name="internalCode" readonly="readonly">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	国际代码<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="internationalCode" name="internationalCode" readonly="readonly">
                    </td>
                </tr>
            </table>
        </div>
        <div style="width:100%;border-bottom:1px solid #000000;">
        	<div style="text-align:center;width:100%;height:10px;"></div>
            <table style="width:100%;">
            	<tr>
                	<td style="width:12%;text-align:right;">
                    	价格来源<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="priceSource" name="priceSource">
                    </td>
                   	<td style="width:12%;text-align:right;">
                   		报价编号<font color="#FFFFFF">*</font>
                   	</td>
                   	<td style="width:21%;padding-left:10px;text-align:left;">
                   		<input type="text" id="enquiryNo" name="enquiryNo" disabled="disabled">
                   	</td>
                    <td style="width:12%;text-align:right;" rowspan="2">
                    	收入备注<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;" rowspan="2">
                    	<textarea id="priceRemarks" name="priceRemarks" style="width:200px;height:60px;"></textarea>
                    </td>
                   
                </tr>
                <tr>
                	<td style="width:12%;text-align:right;">
                    	船公司约号<font color="#FFFFFF" id="yhf">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                        <input type="text" name="yueHao" id="yueHao"/>
                    </td>
                	<td style="width:12%;text-align:right;">
                    	船公司订舱价格<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="priceAmount" name="priceAmount">
                    </td>
                </tr>
                <tr>
                	<td style="width:12%;text-align:right;">
                    	价格开始时间<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="priceStartDate" name="priceStartDate" class="Wdate" readonly="readonly" onClick="WdatePicker({maxDate:'#F{$dp.$D(\'priceEndDate\')}',dateFmt:'yyyy-MM-dd',skin:'whyGreen'})">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	价格停止时间<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="priceEndDate" name="priceEndDate" class="Wdate" readonly="readonly" onClick="WdatePicker({minDate:'#F{$dp.$D(\'priceStartDate\')}',dateFmt:'yyyy-MM-dd',skin:'whyGreen'})">
                    </td>
                      <td style="width:21%;padding-left:10px;text-align:right;">
                                                                                分供方<font color="#FF0000">*</font>
                     </td>
                      <td style="width:21%;padding-left:10px;text-align:left;">
                          <input type="text" id="subsupplier" name="subsupplier" >                                                    
                      </td>
                </tr>
                <tr>
                      <td style="width:12%;text-align:right;">
                    	运费条款<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="carriageType" name="carriageType">
                    </td>
                   
                   
                    <td style="width:12%;text-align:right;">
                    	<span id="s4" style="display:none">第三地名称<font color="#FF0000">*</font></span>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<div id="div4" style="display:none">
                    		<input type="text" id="thirdPlace" name="thirdPlace">
                    	</div>
                    </td>
                      <td style="width:12%;text-align:right;">
                    	运输条款<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="transportItem" name="transportItem">
                    </td>
                   
                </tr>
                <tr>
                <td style="width:12%;text-align:right;">
                    	是否买舱<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<select id="isBuyClass" name="isBuyClass">
                    		<option value="0">否</option>
                    		<option value="1">是</option>
                    	</select>
                    </td>
                    <td style="width:12%;text-align:right;">
                    	其他运费条款<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="feeItem" name="feeItem">
                    </td>
                    
                </tr>
            </table>
        </div>
        <div style="width:100%;border-bottom:1px solid #000000;">
        	<div style="text-align:center;width:100%;height:10px;"></div>
            <table style="width:100%;">
            	<tr>
                	<td style="width:12%;text-align:right;">
                    	报关方式<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="gateType" name="gateType">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	报关行<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="gateUnit" name="gateUnit">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	报关票数<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="gateNum" name="gateNum">
                    </td>
                </tr>
                <tr>
                	<td style="width:12%;text-align:right;">
                    	商检票数<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="sjNum" name="sjNum">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	申报地海关<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="customDistrict" name="customDistrict">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	报关要求<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<textarea style="width:200px;height:80px" id="gateRemark" name="gateRemark"></textarea>
                    </td>
                </tr>
                <tr>
                	<td style="width:12%;text-align:right;">
                    	是否安排拖车<font color="#FFFFFF">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<select id="isTrailer" name="isTrailer">
                    		<option value="0"></option>
                    		<option value="1">自拖车</option>
                    		<option value="2">委托拖车</option>
                    	</select>
                    	<a id="trailerInfo" style="display:none">编辑拖车信息</a>
                    </td>
                </tr>
                <tr style="display:none" id="trailerTr">
                	<td style="width:12%;text-align:right;">&nbsp;</td>
                	<td colspan="5" style="text-align: center;width:100%">
                		<table id="trailerShowTab" align="center"></table>
                	</td>
                </tr>
               <tr>
               		<td style="width:12%;text-align:right;">
                    	代办保险<font color="#FF0000">*</font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="insurance" name="insurance">
                    </td>
               		<td style="width:12%;text-align:right;">
                    	装箱方式<font color="#FF0000">*</font>
                    </td>
                    <td style="padding-left:10px;text-align:left;width:21%;">
                    	<input type="checkbox" id="loadType0" name="loadType0" value="0">
                    	<label for="loadType0">厂装</label>
                    	<input type="checkbox" id="loadType1" name="loadType1" value="1">
                    	<label for="loadType1">港装</label>
                    </td>
                    <td style="width:12%;text-align:right;">
                    	&nbsp;
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="checkbox" id="isStifling" name="isStifling" value="y">
                    	<label for="isStifling">是否熏蒸</label>
                    </td>
               </tr>
               <tr>
                    <td style="width:12%;text-align:right;">
                    	<span id="s7" style="display:none">保险名称</span>
                    </td>
        			<td style="width:21%;padding-left:10px;text-align:left;">
        				<input type="text" id="bxmc" name="bxmc" style="display:none">
        			</td>
        			<td style="width:12%;text-align:right;">
        				<span id="s8" style="display:none">保险金额</span>
        			</td>
        			<td style="width:21%;padding-left:10px;text-align:left;">
        				<input type="text" id="bxje" name="bxje" style="display:none">
        			</td>
        			<td style="width:12%;text-align:right;">
        				<span id='s9' style="display:none">保险比率</span>
        			</td>
        			<td style="width:21%;padding-left:10px;text-align:left;">
        				<input type="text" id="bxbl" name="bxbl" style="display:none">
        			</td>
               </tr>
               <tr id="tr11" style="display:none">
        			<td style="width:12%;text-align:right;">保险备注</td>
        			<td style="width:21%;padding-left:10px;text-align:left;">
        				<textarea style="width:200px;height:80px;" id="bz" name="bz"></textarea>
        			</td>
               </tr>
               <tr>
               		<td style="width:12%;text-align:right;">
               			<font id="cz" style="display:none">厂装箱型箱量</font><br><br>
               			<font id="gz" style="display:none">港装箱型箱量</font>
                    </td>
                    <td style="padding-left:10px;text-align:left;width:100%;" colspan="3">
                    	<input type="text" id="loadBox0" name="loadBox0" style="width:100%;display:none;" onblur="checkBoxType(this)"><br><br>
                    	<input type="text" id="loadBox1" name="loadBox1" style="width:100%;display:none;" onblur="checkBoxType(this)">
                    </td>
                    <td style="width:12%;text-align:right;" rowspan="2">
                  		<span id="lbrf" style="display:none">港装要求<font color="#FFFFFF">*</font></span>
                  	</td>
                  	<td style="width:21%;padding-left:10px;text-align:left;" rowspan="2">
                  		<textarea style="width:200px;height:80px;display:none;" id="loadBoxRemark" name="loadBoxRemark"></textarea>
                  	</td>
               </tr>
               <tr id="tr3" style="display:none">
                  	<td style="width:12%;text-align:right;">
                  		装箱时间<font color="#FFFFFF">*</font>
                  	</td>
                  	<td style="width:21%;padding-left:10px;text-align:left;">
                  		<input type="text" id="harbourDate" name="harbourDate" class="Wdate" readonly="readonly" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',skin:'whyGreen'})">
                  	</td>
                  	<td style="width:12%;text-align:right;">
                  		预约摆箱时间<font color="#FFFFFF">*</font>
                  	</td>
                  	<td style="width:21%;padding-left:10px;text-align:left;">
                  		<input type="text" id="orderBoxDate" name="orderBoxDate" class="Wdate" readonly="readonly" 
                  		onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'pickBoxDate\')}',skin:'whyGreen'})">
                  	</td>
               </tr>
               <tr id="tr10" style="display:none">
		       		<td style="width:12%;text-align:right;">
		        		货物件数及单位<font color="#FFFFFF">*</font>
		        	</td>
		        	<td style="width:21%;padding-left:10px;text-align:left;">
		        		<input type="text" id="harbourPkgs" name="harbourPkgs" style="width:65px">
		        		<input type="text" id="harbourPackage" name="harbourPackage" style="width:125px">
		        	</td>
		        	<td style="width:12%;text-align:right;">
	               		货物毛重<font color="#FFFFFF">*</font>
	               	</td>
	               	<td style="width:21%;padding-left:10px;text-align:left;">
	               		<input type="text" id="harbourKg" name="harbourKg" style="width:170px;"> KGS
	               	</td>
	               	<td style="width:12%;text-align:right;">
	               		体积<font color="#FFFFFF">*</font>
	               	</td>
	               	<td style="width:21%;padding-left:10px;text-align:left;">
	               		<input type="text" id="harbourVolume" name="harbourVolume" style="width:170px;"> CBM
	               	</td>
               </tr>
               </table>
              <table style="width:100%;">
               <div style="width:100%;border-bottom:1px solid #000000;">
              <div style="text-align:center;width:100%;height:10px;"></div>
                <tr id="t1">
                	<td style="width:12%;text-align:right;">
                    	预计江船装船时间<font color="#FF0000"></font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="loadDate" name="loadDate" class="Wdate" readonly="readonly" onClick="WdatePicker({dateFmt:'yyyy-MM-dd',skin:'whyGreen'})">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	指定海船航线<font color="#FFFFFF"></font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="shipLine" name="shipLine">
                    </td>
                	<td style="width:12%;text-align:right;">
                		预计放箱时间<font color="#FF0000"></font>
                	</td>
                	<td style="width:21%;padding-left:10px;text-align:left;">
                		<input type="text" id="putBoxDate" name="putBoxDate" class="Wdate" readonly="readonly" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',skin:'whyGreen'})">
                	</td>
                </tr>
                <tr>
                	<td style="width:12%;text-align:right;">
                		预计提箱时间<font color="#FF0000"></font>
                	</td>
                	<td style="width:21%;padding-left:10px;text-align:left;">
                		<input type="text" id="pickBoxDate" name="pickBoxDate" class="Wdate" readonly="readonly" onClick="WdatePicker({dateFmt:'yyyy-MM-dd',skin:'whyGreen'})">
                	</td>
                	<td style="width:12%;text-align:right;">
                    	指定预计海船期<font color="#FFFFFF"></font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="shippingDate" name="shippingDate" class="Wdate" readonly="readonly" onClick="WdatePicker({dateFmt:'yyyy-MM-dd',skin:'whyGreen'})">
                    </td>
                    <td style="width:12%;text-align:right;">
                    	指定预计海船到港期<font color="#FFFFFF"></font>
                    </td>
                    <td style="width:21%;padding-left:10px;text-align:left;">
                    	<input type="text" id="preSeashipStopDate" name="preSeashipStopDate" class="Wdate" readonly="readonly" onClick="WdatePicker({dateFmt:'yyyy-MM-dd',skin:'whyGreen'})">
                    </td>
                </tr>
               <tr>
               		<td style="width:12%;text-align:right;">
                    	操作备注<font color="#FFFFFF">*</font>
                    </td>
                    <td colspan="5" style="padding-left:10px;text-align:left;">
                    	<textarea id="remarks" name="remarks" style="width:98%;height:100px;"></textarea>
                    </td>
               </tr>
             </table>
            
        </div>
        <div style="width:100%;text-align:center;margin-top:20px;">
        	<a id="save">保存</a>&nbsp;&nbsp;&nbsp;&nbsp;
        	<a id="reset">重置</a>&nbsp;&nbsp;&nbsp;&nbsp;
        	<a id="goback">返回</a>
        	<input type="hidden" id="userId" name="userId">
        	<input type="hidden" id="startInputTime" name="startInputTime">
        	<input type="hidden" id="endInputTime" name="endInputTime">
        </div>
        <input type="hidden" id="aa" name="aa">
        <input type="hidden" id="trailerType" name="trailerType">
        <input type="hidden" id="devanningType" name="devanningType">
        <input type="hidden" id="trailerAddress" name="trailerAddress">
        <input type="hidden" id="trailerRemarks" name="trailerRemarks">
        <input type="hidden" id="returnBoxAddress" name="returnBoxAddress">
        <input type="hidden" id="trailerDate" name="trailerDate">
        <input type="hidden" id="trailerPrice" name="trailerPrice">
        <input type="hidden" id="trailerContact" name="trailerContact">
        <input type="hidden" id="trailerContactInfo" name="trailerContactInfo">
    </form>
    <div id="boxListDiv">
    	<table id="boxListTab"></table><br>
    	<input type="text" id="boxtype" readonly="readonly">
    	<input type="text" id="boxnum">
    	<a id="boxOk">确认</a>
    	<a id="boxAdd">添加到托单</a>
    	<a id="boxDel">删除</a>
    	<table style="display:none" id="table1">
    		<tr>
    			<td>长</td>
    			<td>
    				<input type="text" id="length" name="tt">m
    			</td>
    			<td>宽</td>
    			<td>
					<input type="text" id="width" name="tt">m
				</td>
    			<td>高</td>
    			<td>
    				<input type="text" id="height" name="tt">m
    			</td>
    			<td>左超</td>
    			<td>
    				<input type="text" id="overLeft" name="tt">m
    			</td>
    			<td>右超</td>
    			<td>
					<input type="text" id="overRight" name="tt">m
				</td>
    		</tr>
    		<tr>
    			<td>前超</td>
    			<td>
    				<input type="text" id="overFore" name="tt">m
    			</td>
    			<td>后超</td>
    			<td>
					<input type="text" id="overBack" name="tt">m
				</td>
    			<td>超高</td>
    			<td>
    				<input type="text" id="overHeight" name="tt">m
    			</td>
    			<td>超限</td>
    			<td>
    				<input type="text" id="overLimit" name="tt">m
    			</td>
    			<td>体积</td>
    			<td>
    				<input type="text" id="volume" name="tt">CBM
    			</td>
    		</tr>
    	</table>
    	<br>
    	<table id="boxList"></table>
    </div>
    <div id="boxNoListDiv" style="text-align:center;;">
    	箱号&nbsp;<textarea id="boxno" style="width:350px;height:80px; vertical-align:middle;"></textarea>
    	<div style="width:100%;text-align:left;margin-top:5px;">
    		箱型&nbsp;<input type="text" id="box_no_type">
    	</div>
    	<div style="margin-top:5px;margin-bottom:5px;">
    		<a id="boxNoOk">确认</a>
	    	<a id="boxNoAdd">添加到托单</a>
	    	<a id="boxNoDel">删除</a>
    	</div>
    	<div id="noDiv">
    		<table id="boxNoList"></table>
    	</div>
    </div>
   
    <div id="trailerInfoDiv" style="text-align:center;">
    	<table>
    		<tr>
    			<td style="width:12%;text-align:right;">
              		拖车类型
              	</td>
              	<td style="width:21%;padding-left:10px;text-align:left;">
              		<select id="trailerType0">
              			<option value="0">起运港拖车</option>
              			<option value="1">目的港拖车</option>
              		</select>
              	</td>
              	<td style="width:12%;text-align:right;">
              		拖车时间<font color="#FFFFFF">*</font>
              	</td>
              	<td style="width:21%;padding-left:10px;text-align:left;">
              		<input type="text" id="trailerDate0" name="trailerDate0" class="Wdate" readonly="readonly" onClick="WdatePicker({dateFmt:'yyyy-MM-dd',skin:'whyGreen'})">
              	</td>
              	<td style="width:12%;text-align:right;">
              		拆装箱类型<font color="#FFFFFF">*</font>
              	</td>
              	<td style="width:21%;padding-left:10px;text-align:left;">
					<select id="devanningType0">
              			<option value="0">拆箱</option>
              			<option value="1">装箱</option>
              		</select>              	
              	</td>
    		</tr>
    		<tr>
	        	<td style="width:12%;text-align:right;">
              		地址<font color="#FFFFFF">*</font>
              	</td>
              	<td style="width:21%;padding-left:10px;text-align:left;">
              		<textarea style="width:200px;height:80px;" id="trailerAddress0" name="trailerAddress0"></textarea>
              	</td>
              	<td style="width:12%;text-align:right;">
              		拖车备注<font color="#FFFFFF">*</font>
              	</td>
              	<td style="width:21%;padding-left:10px;text-align:left;">
              		<textarea style="width:200px;height:80px;" id="trailerRemarks0" name="trailerRemarks0"></textarea>
              	</td>
              	<td style="width:12%;text-align:right;">
              		还箱地<font color="#FFFFFF">*</font>
              	</td>
              	<td style="width:21%;padding-left:10px;text-align:left;">
              		<textarea style="width:200px;height:80px;" id="returnBoxAddress0" name="returnBoxAddress0"></textarea>
              	</td>
             </tr>
             <tr>
              	<td style="width:12%;text-align:right;">
              		拖车价格<font color="#FFFFFF">*</font>
              	</td>
              	<td style="width:21%;padding-left:10px;text-align:left;">
              		<input type="text" id="trailerPrice0" name="trailerPrice0">
              	</td>
              	<td style="width:12%;text-align:right;">
              		联系人<font color="#FFFFFF">*</font>
              	</td>
              	<td style="width:21%;padding-left:10px;text-align:left;">
              		<input type="text" id="trailerContact0" name="trailerContact0">
              	</td>
              	<td style="width:12%;text-align:right;">
              		联系方式<font color="#FFFFFF">*</font>
              	</td>
              	<td style="width:21%;padding-left:10px;text-align:left;">
              		<input type="text" id="trailerContactInfo0" name="trailerContactInfo0">
              	</td>
             </tr>
             <tr>
             	<td colspan="6" style="text-align: center;">
             		<a id="trailerAdd">新增</a>
             		<a id="trailerEdit">修改</a>
             		<a id="trailerDel">删除</a>
             	</td>
             </tr>
    	</table>
    	<table id="trailerInfoTab"></table>
    </div>
 
    <div >
        <table height="400">
    		 <tr>
               		<td style="width:12%;text-align:right;">
                    
                    </td>
                    
               </tr>
      </table>
    </div>

</body>
<script type="text/javascript">
	//验证不能输入中文
	function checkInput(id,message){
		var s = $("#"+id).val();
		for (var i = 0; i < s.length; i++) {
			var c = s.charCodeAt(i);
			if (c > 0xFF || c < 0){
				$.messager.alert("错误",message+"中不能有中文字符!","error");
				$('#'+id).css("border","1px red solid");
				return false;	
			}else{
				$('#'+id).css("border","1px #95B8E7 solid");
			}
		}
		return true;
	}
	//计算装箱方式中的箱型箱量
	function calculateBox(element){
		//离开装箱方式箱型输入框时先分配两个输入框的箱型箱量再进行判断比较
		var bt = element.value;
		var bts = null;
		if(""!=bt){
			bts = bt.split("&&");
		}
		//将当前元素的箱型箱量放入Map集合中
		var thisType={};
		var length=0;
		if(bts!=null){
			for(var i=0;i<bts.length;i++){
				var num=bts[i].split("X")[0];
				var type=bts[i].split("X")[1];
				if(thisType[type]==undefined){
					thisType[type]=Number(num);
					length=length+1;
				}else{
					thisType[type]=thisType[type]+Number(num);
				}
			}
		}
		//判断如果存在两种装箱方式则自动计算箱型箱量
		if($("#loadType0").is(':checked')&&$("#loadType1").is(':checked')){
			var val = "";
			for(var i=0;i<boxTypeTotals.length;i++){
				var num=boxTypeTotals[i].split("X")[0];
				var type=boxTypeTotals[i].split("X")[1];
				if(thisType[type]==undefined){
					val += num+"X"+type+"&&";
				}else{
					if(Number(num)-thisType[type]>0){
						val += (Number(num)-thisType[type])+"X"+type+"&&";
					}
				}
			}
			if(val!=""){
				val = val.substring(0,val.length-2);
			}
			if(element.id=="loadBox0"){
				$("#loadBox1").val(val);
			}else if(element.id=="loadBox1"){
				$("#loadBox0").val(val);
			}
		}
	}
	//判断装箱方式中的箱型箱量和总的是否一致
	function checkBoxType(element){
		//获取总的箱型箱量
		var boxTypeTotal=$("#boxType").val();
		var boxTypeTotals=null;
		if(""!=boxTypeTotal){
			boxTypeTotals=boxTypeTotal.split("&&");
		}
		//计算箱型箱量
		if(undefined!=element){
			calculateBox(element);
		}
		//获取装箱方式中的箱型箱量
		var boxTypeCz=$("#loadBox0").val();
		var boxTypeCzs=null
		if(""!=boxTypeCz){
			boxTypeCzs=boxTypeCz.split("&&");
		}
		var boxTypeGz=$("#loadBox1").val();
		var boxTypeGzs=null;
		if(""!=boxTypeGz){
			boxTypeGzs=boxTypeGz.split("&&");
		}
		//将装箱方式中的箱型箱量存到类Map集合中去
		var hasType={};
		var length=0;
		if(boxTypeCzs!=null){
			for(var i=0;i<boxTypeCzs.length;i++){
				var num=boxTypeCzs[i].split("X")[0];
				var type=boxTypeCzs[i].split("X")[1];
				if(hasType[type]==undefined){
					hasType[type]=Number(num);
					length=length+1;
				}else{
					hasType[type]=hasType[type]+Number(num);
				}
			}
		}
		if(boxTypeGzs!=null){
			for(var i=0;i<boxTypeGzs.length;i++){
				var num=boxTypeGzs[i].split("X")[0];
				var type=boxTypeGzs[i].split("X")[1];
				if(hasType[type]==undefined){
					hasType[type]=Number(num);
					length=length+1;
				}else{
					hasType[type]=hasType[type]+Number(num);
				}
			}
		}
		if(length!=boxTypeTotals.length){
			$.messager.alert("警告","装箱方式中的箱型箱量与总箱型箱量不匹配!","warning");
			return false;
		}
		for(var i=0;i<boxTypeTotals.length;i++){
			var num=boxTypeTotals[i].split("X")[0];
			var type=boxTypeTotals[i].split("X")[1];
			if(hasType[type]==undefined){
				$.messager.alert("警告","装箱方式中的箱型箱量与总箱型箱量不匹配!","warning");
				return false;
			}else{
				if(hasType[type]!=Number(num)){
					$.messager.alert("警告","装箱方式中的箱型箱量与总箱型箱量不匹配!","warning");	
					return false;
				}
			}
		}
		return true;
	}
	var flagd=0;
	var flagcd=0;
	//检查是否危险品
	function checkDangerous(val){
		$.ajax({
			type:"POST",
			url:"consignMgr/selectDangerous.do",
			dataType:"json",
			data:{keywords:val},
			success:function(data){
				$.each(data,function(key,value){
					$.messager.confirm('危险品确认',value,function(r){
						if(r){
							$("#tr8").show();
							$("#tr9").show();
							$("#s3").show();
							$("#div3").show();
							$("#s2").hide();
							$("#div2").hide();
							$("#s5").show();
			    			$("#div7").show();
			    			$("#dangerousName").combogrid("grid").datagrid("reload",{keyword:val});
			    			$("#dangerousName").combogrid("setValue",val);
			    			$("#goodsType").combobox("setText","危险品");
			    			$("#goodsType").combobox("setValue","危险品");
						}else{
							$("#tr8").hide();
							$("#tr9").hide();
							$("#s3").hide();
							$("#div3").hide();
							$("#s5").hide();
			    			$("#div7").hide();
			    			$("#goodsType").combobox("setText","普通货物");
			    			$("#goodsType").combobox("setValue","普通货物");
			    			$("#goodsType").val("普通货物");
			    			//删除数据
				    		$('#dangerousName').combogrid('clear');
							$("#dangerousType").val('');
							$("#dangerousLevel").val('');
							$("#internalCode").val('');
							$("#internationalCode").val('');
						}
					});
				});
			}
		});
	}
	$(function(){
		try {
			$("input[type=text]").css("border","1px solid #95B8E7");
			$("select").css("border","1px solid #95B8E7");
			$("textarea").css("border","1px solid #95B8E7");
			$("input[type=text][name!=tt][id!=goodsPkgs][id!=harbourPkgs][id!=harbourPackage][id!=goodsWeight][id!=goodsMeasurment][id!=harbourKg][id!=harbourVolume]").css("width","197px");
			$("input[type=text][id=boxtype]").css("width","100px");
			$("input[type=text][id=boxnum]").css("width","100px");
			$("input[type=text][id=boxno]").css("width","100px");
			$("#tradeCode,#tyr,#jhd,#xhg,#selfCode").css("width","100px");
			$("#freeDayRemark").css("width","98%");
			$("#boxNo").css("width","98%");
			$("#boxType").css("width","98%");
			$("#loadBox0").css("width","70%");
			$("#loadBox1").css("width","70%");
		} catch (e) {
			
		}
		
		$("#length").numberbox({
			width:40,
			precision:2
		});
		$("#length").blur(function(){
			var volume = Number($("#length").val())*Number($("#width").val())*Number($("#height").val());
			$("#volume").numberbox("setValue",volume);
		});
		$("#width").numberbox({
			width:40,
			precision:2
		});
		$("#width").blur(function(){
			var volume = Number($("#length").val())*Number($("#width").val())*Number($("#height").val());
			$("#volume").numberbox("setValue",volume);
		});
		$("#height").numberbox({
			width:40,
			precision:2
		});
		$("#height").blur(function(){
			var volume = Number($("#length").val())*Number($("#width").val())*Number($("#height").val());
			$("#volume").val(volume);
		});
		$("#overLeft").numberbox({
			width:40,
			precision:2
		});
		$("#overRight").numberbox({
			width:40,
			precision:2
		});
		$("#overBack").numberbox({
			width:40,
			precision:2
		});
		$("#overFore").numberbox({
			width:40,
			precision:2
		});
		$("#overLimit").numberbox({
			width:40,
			precision:2
		});
		$("#overHeight").numberbox({
			width:40,
			precision:2
		});
		$("#volume").numberbox({
			width:80,
			precision:2
		});
		
		//查询导入
		$("#search").linkbutton({
			iconCls:"icon-import",
			width:100
		});
		$('#searchImport').window({
			title:'导入托单',
		    width:900,
		    height:400,
		    minimizable:false,
		    maximizable:false,
		    resizable:false,
		    closed:true,
		    top:0,
		    modal:true,
		    iconCls:'icon-import'
		});
		$("#search").bind("click",function(){
			$('#searchImport').window("open");
			var keyword = $("#tdh").val();
			$("#tradeCode").val(keyword);
			$("#tradeList").datagrid("reload",{tradeCode:keyword,tradeType:'wmx'});
		});
		//托单列表
		$("#tradeList").datagrid({
			width:880,
			height:330,
			striped:true,
			singleSelect:true,
			pagination:true,
			loadMsg:'数据加载中,请稍后。。。',
			url:'consignMgr/getTradeListForImport.do',
			queryParams:{tradeType:'1'},
			columns:[[
			    {field:'trade_code',title:'进仓编号',width:120,align:'center'},
			    {field:'agency_self_no',title:'托运人自编号',width:100,align:'center'},
				{field:'input_date',title:'录入时间',width:100,align:'center'},
				{field:'agency_man',title:'托运人',width:320},
				{field:'port_of_discharge',title:'卸货港',width:100},
				{field:'stop_harbour',title:'交货地',width:100}
			]],
			onDblClickRow:function(index,row){
				getConsignInfo(row.trade_code);
				$("#tdh").val(row.trade_code);
				$("#searchImport").window("close");
			}
		});
		//修改拖车信息
		$("#trailerInfo").linkbutton({
			inconCls:'icon-edit'
		});
		$("#trailerInfo").click(function(){
			$("#trailerInfoDiv").dialog("open");
			autoLocation("trailerInfoDiv", "400")
		});
		//新增拖车信息
		$("#trailerAdd").linkbutton({
			iconCls:'icon-add'
		});
		$("#trailerAdd").click(function(){
			var trailerType0=$("#trailerType0").val();
			var trailerAddress0=$("#trailerAddress0").val();
			var trailerRemarks0=$("#trailerRemarks0").val();
			var returnBoxAddress0=$("#returnBoxAddress0").val();
			var trailerDate0=$("#trailerDate0").val();
			var trailerPrice0=$("#trailerPrice0").val();
			var trailerContact0=$("#trailerContact0").val();
			var trailerContactInfo0=$("#trailerContactInfo0").val();
			var devanningType0=$("#devanningType0").val();
			if("1"==trailerType0){
				trailerType0="目的港拖车";
			}else{
				trailerType0="起运港拖车";
			}
			if("1"==devanningType0){
				devanningType0="装箱";
			}else{
				devanningType0="拆箱";
			}
			$("#trailerInfoTab").datagrid('appendRow',{trailer_type:trailerType0,trailer_address:trailerAddress0,
				trailer_remarks:trailerRemarks0,trailer_date:trailerDate0,trailer_price:trailerPrice0,devanning_type:devanningType0,
				trailer_contact:trailerContact0,trailer_contact_info:trailerContactInfo0,return_box_address:returnBoxAddress0});
			$("#trailerType0").val("");
			$("#devanningType0").val("");
			$("#returnBoxAddress0").val("");
			$("#trailerAddress0").val("");
			$("#trailerRemarks0").val("");
			$("#trailerDate0").val("");
			$("#trailerPrice0").val("");
			$("#trailerContact0").val("");
			$("#trailerContactInfo0").val("");
		});
		//修改拖车信息
		$("#trailerEdit").linkbutton({
			iconCls:'icon-edit'
		});
		$("#trailerEdit").click(function(){
			var trailerType0 = $("#trailerType0").val();
			if("1"==trailerType0){
				trailerType0='目的港拖车';
			}else{
				trailerType0='起运港拖车';
			}
			var devanningType0=$("#devanningType0").val();
			if("1"==devanningType0){
				devanningType0="装箱";
			}else{
				devanningType0="拆箱";
			}
			var trailerAddress0=$("#trailerAddress0").val();
			var trailerRemarks0=$("#trailerRemarks0").val();
			var returnBoxAddress0=$("#returnBoxAddress0").val();
			var trailerDate0=$("#trailerDate0").val();
			var trailerPrice0=$("#trailerPrice0").val();
			var trailerContact0=$("#trailerContact0").val();
			var trailerContactInfo0=$("#trailerContactInfo0").val();
			$('#trailerInfoTab').datagrid('updateRow',{
				index:aaIndex,
				row: {
					devanning_type: devanningType0,
					trailer_type: trailerType0,
					trailer_address: trailerAddress0,
					trailer_remarks: trailerRemarks0,
					return_box_address: returnBoxAddress0,
					trailer_date: trailerDate0,
					trailer_price: trailerPrice0,
					trailer_contact: trailerContact0,
					trailer_contact_info: trailerContactInfo0
				}
			});
			$("#trailerType0").val("");
			$("#devanningType0").val("");
			$("#trailerAddress0").val("");
			$("#trailerRemarks0").val("");
			$("#returnBoxAddress0").val("");
			$("#trailerDate0").val("");
			$("#trailerPrice0").val("");
			$("#trailerContact0").val("");
			$("#trailerContactInfo0").val("");
		});
		//删除拖车信息
		$("#trailerDel").linkbutton({
			iconCls:'icon-cancel'
		});
		$("#trailerDel").click(function(){
			var rows=$("#trailerInfoTab").datagrid("getSelections");
			if(rows.length<=0){
				$.messager.alert("提示","请选择删除的记录","info");
				return;
			}
			for(var i=0;i<rows.length;i++){
				var rowIndex = $("#trailerInfoTab").datagrid("getRowIndex",rows[i]);
				$("#trailerInfoTab").datagrid("deleteRow",rowIndex);
			}
		});
		//拖车信息修改DIV
		$("#trailerShowTab").datagrid({
			width:930,
			singleSelect:true,
			striped:true,
			url:'consignMgr/getTrailerInfo.do',
			columns:[[    
		          {field:'trailer_type',title:'拖车类型',width:50},
		          {field:'devanning_type',title:'拆装箱类型',width:80},
		          {field:'trailer_address',title:'地址',width:150},
		          {field:'trailer_remarks',title:'拖车备注',width:150},
		          {field:'return_box_address',title:'还箱地',width:150},
		          {field:'trailer_date',title:'拖车日期',width:80},
		          {field:'trailer_price',title:'拖车价格',width:80},
		          {field:'trailer_contact',title:'联系人',width:100},
		          {field:'trailer_contact_info',title:'联系方式',width:100}
		    ]]
		});
		//设置表格title信息
		tooltip("trailerShowTab","200px");
		var ttindex=0;
		$("#trailerInfoDiv").dialog({
			title:'拖车信息修改',
			width:970,
			height:400,
			modal:true,
			closed:true,
			onClose:function(){
				//托单界面显示拖车信息
				var rows=null
				try{
					rows = $("#trailerShowTab").datagrid("getRows");
					for(var i=0;i<rows.length;){
						$('#trailerShowTab').datagrid('deleteRow',0);
					}
					$("#trailerShowTab").datagrid("destroy",true)
				}catch(e){
					
				}
				try {
					rows = $("#trailerInfoTab").datagrid("getRows");
					if(rows.length>0){
						$("#trailerTr").show();
					}else{
						$("#trailerTr").hide();
					}
					for(var i=0,j=rows.length;i<j;i++){
						$('#trailerShowTab').datagrid('appendRow',rows[i]);
					}
					if(rows.length>0){
						$("#trailerTr").show();
					}
				} catch (e) {
					
				}
			}
		});
		var aaIndex="";
		//拖车信息列表
		$("#trailerInfoTab").datagrid({
			width:930,
			height:190,
			columns:[[
		          {field:'trailer_type',title:'拖车类型',width:50},
		          {field:'devanning_type',title:'拆装箱类型',width:80},
		          {field:'trailer_address',title:'地址',width:150},
		          {field:'trailer_remarks',title:'拖车备注',width:150},
		          {field:'return_box_address',title:'还箱地',width:150},
		          {field:'trailer_date',title:'拖车日期',width:80},
		          {field:'trailer_price',title:'拖车价格',width:80},
		          {field:'trailer_contact',title:'联系人',width:100},
		          {field:'trailer_contact_info',title:'联系方式',width:100}
		      ]],
			onClickRow:function(index,row){
				aaIndex=index;
				var trailerType0=row.trailer_type;
				var devanningType0=row.devanning_type;
				var trailerAddress0=row.trailer_address;
				var trailerRemarks0=row.trailer_remarks;
				var returnBoxAddress0=row.return_box_address;
				var trailerDate0=row.trailer_date;
				var trailerPrice0=row.trailer_price;
				var trailerContact0=row.trailer_contact;
				var trailerContactInfo0=row.trailer_contact_info;
				if("目的港拖车"==trailerType0){
					trailerType0='1';
				}else{
					trailerType0='0';
				}
				if("装箱"==devanningType0){
					devanningType0="1";
				}else{
					devanningType0="0";
				}
				$("#trailerType0").val(trailerType0);
				$("#devanningType0").val(devanningType0);
				$("#trailerAddress0").val(trailerAddress0);
				$("#trailerRemarks0").val(trailerRemarks0);
				$("#returnBoxAddress0").val(returnBoxAddress0);
				$("#trailerDate0").val(trailerDate0);
				$("#trailerPrice0").val(trailerPrice0);
				$("#trailerContact0").val(trailerContact0);
				$("#trailerContactInfo0").val(trailerContactInfo0);
			}
		});
		//查询销售员
		$("#salesManName").combogrid({
			panelWidth:540,
			width:200,
			striped:true,
			pagination:true,
			showHeader:true,
			idField: 'id_',    
		    textField: 'name_', 
			url:"consignMgr/getSalesPerson.do",
			columns: [[
				{field:'name_',title:'销售员姓名',width:170},
				{field:'department',title:'所属部门',width:170},
				{field:'company_name',title:'所属公司',width:175},
				{field:'id_',title:'销售员ID',hidden:true},
				{field:'company_code',title:'公司ID',hidden:true},
				{field:'departmentid',title:'部门ID',hidden:true}
			]],
			onClickRow:function(){
				salesManName();
			},
			keyHandler: {
				//
				enter:function(){
					var record = pressEnter("salesManName");
					if(record!=null){
						var department = record[0].department;
        				var name = record[0].name_;
        				var id_ = record[0].id_;
        				var idname=record[0].idname;
        				var departmentid = record[0].departmentid;
        				var companyName = record[0].company_name;
        				var companyCode = record[0].company_code;
        				
        				$("#salesManName").combogrid("setValue",id_+"@"+name);
						$("#salesManName").combogrid("setText",name);
						$("#salesManDep").val(departmentid+"@"+department);						
						$("#salesManDepShow").val(department);
						$("#salesManAgent").val(companyCode+"@"+companyName);
        				$("#salesManAgentShow").val(companyName);
        				$("#salesManName").val(id_);
					}
                },
                //按上方向键移动选择行
                up:function(){
                	pressUp("salesManName");
                    salesManName();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("salesManName");
                    salesManName();
                },
                //搜索功能
				query: function(q){
					keyword = q;
					//动态搜索  
					$('#salesManName').combogrid("grid").datagrid("reload",{'keyword':keyword});
					
					$('#salesManName').combogrid("setValue",keyword);
					$("#salesManName").val("");
					$("#salesManDepShow").val("");
    				$("#salesManDep").val("");
    				$("#salesManAgentShow").val("");
    				$("#salesManAgent").val("");
					$('#salesManName').combogrid("grid").datagrid("reload");
	
					
					
					
				}
			}
		});
		//查询第二销售员
		$("#secondSalesMan").combogrid({
			panelWidth: 540,
			width:200,
			striped:true,
			pagination:true,
			showHeader:true,
			idField: 'id_',    
		    textField: 'name_', 
			url:"consignMgr/getSalesPerson.do",
			columns: [[
				{field:'name_',title:'销售员姓名',width:170},
				{field:'department',title:'所属部门',width:170},
				{field:'company_name',title:'所属公司',width:175},
				{field:'id_',title:'销售员ID',hidden:true},
				{field:'company_code',title:'公司ID',hidden:true},
				{field:'departmentid',title:'部门ID',hidden:true}
			]],
			onClickRow:function(){
				secondSalesMan();
			},
			keyHandler: {
				//按键事件
				enter:function(){
					var record = pressEnter("secondSalesMan");
					if(record!=null){
						var department = record[0].department;
        				var name = record[0].name_;
        				var id_ = record[0].id_;
        				var departmentid = record[0].departmentid;
        				var companyName = record[0].company_name;
        				var companyCode = record[0].company_code;
        				
        				$("#secondSalesMan").combogrid("setValue",id_+"@"+name);
						$("#secondSalesMan").combogrid("setText",name);
						$("#secondSalesManDep").val(departmentid+"@"+department);
						$("#secondSalesManDepShow").val(department);
						$("#secondSalesAgent").val(companyCode+"@"+companyName);			
						$("#secondSalesAgentShow").val(companyName);
						$("#secondSalesMan").val(id_);
					
					}
                },
                //按上方向键移动选择行
                up:function(){
                    pressUp("secondSalesMan");
                    secondSalesMan();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("secondSalesMan");
                    secondSalesMan();
                },
				query: function(q) {
					keyword = q;
					//动态搜索  
					$('#secondSalesMan').combogrid("grid").datagrid("reload",{'keyword':keyword});
					$('#secondSalesMan').combogrid("setValue",keyword);
					$("#secondSalesMan").val("");
					$("#secondSalesManDep").val("");
    				$("#secondSalesManDepShow").val("");
    				$("#secondSalesAgent").val("");
    				$("#secondSalesAgentShow").val("");
					$('#secondSalesMan').combogrid("grid").datagrid("reload");
				}
			}
		});
		//是否套约
		$("#isTaoyue").click(function(){
			var isChoose = $("#isTaoyue").prop("checked");
			if(isChoose){
				$("#s1").show();
				$("#tr1").show();
				$("#div1").show();
				$("#d1").show();
				$("#d2").show();
			}else{
				$("#s1").hide();
				$("#tr1").hide();
				$("#div1").hide();
				$("#d1").hide();
				$("#d2").hide();
				//设置输入框值为空
				$("#secondSalesMan").combogrid("clear");
				$("#secondSalesManDep").val("");
				$("#secondSalesManDepShow").val("");
				$("#secondSalesAgent").val("");
				$("#secondSalesAgentShow").val("");
			}
		});
		//查询货主
		$("#agencyContact").combogrid({
			panelWidth: 570,
			width:200,
			striped:true,
			pagination:true,
			showHeader:true,			
			idField: 'id_',    
		    textField: 'customer_name', 
			url:"consignMgr/getCustomer.do",		
			queryParams:{tradeFlag:2},
			columns: [[
				{field:'spell_code',title:'检索码',width:50},
				{field:'customer_name',title:'托运人全称',width:205},
				{field:'nm_account_type',title:'付款方式',width:80},
				{field:'customer_type',title:'客户类别',width:50},
				{field:'stop_date',title:'客户协议期',width:100},
				{field:'ac',title:'状态',width:50}
			]],
			onClickRow:function(){
				agencyContact();
			},
			keyHandler: {
				//按键事件
				enter:function(){
					var record = pressEnter("agencyContact");
					if(record!=null){
						var flag = record[0].ac;
						var id=record[0].id_;
        				var customerName = record[0].customer_name;
        				if(!judgeCustomer("agencyContact",flag)){
        					return;
        				}
        				$('#agencyContact').combogrid("setValue",id+"@"+customerName);
        				$('#agencyContact').combogrid("setText",customerName);
    					$('#agencyContact').val(customerName);
					}
                },
                //按上方向键移动选择行
                up:function(){
                	pressUp("agencyContact");
                    agencyContact();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("agencyContact");
                    agencyContact();
                },
				query: function(q) {
					likeSelect(q,"agencyContact");
				}
			}
		});
		//查询托运人
		$("#agencyMan").combogrid({
			panelWidth: 570,
			width:200,
			striped:true,
			pagination:true,
			showHeader:true,
			idField: 'id_',    
		    textField: 'customer_name', 
			url:"consignMgr/getCustomer.do",		
			queryParams:{tradeFlag:2},
			columns: [[
				{field:'spell_code',title:'检索码',width:50},
				{field:'customer_name',title:'托运人全称',width:205},
				{field:'nm_account_type',title:'付款方式',width:80},
				{field:'customer_type',title:'客户类别',width:50},
				{field:'stop_date',title:'客户协议期',width:100},
				{field:'work_man',title:'托运人联系人',hidden:true},
				{field:'work_phone',title:'托运人联系方式',hidden:true},
				{field:'ac',title:'状态',width:50}
			]],			
			
			onClickRow:function(){
				agencyMan();
			},
			keyHandler: {
				//按键事件
				enter:function(){
					var record = pressEnter("agencyMan");
					if(record!=null){
						var flag = record[0].ac;
						var id= record[0].id_;
        				var customerName = record[0].customer_name;
        				var contact = record[0].work_man;
        				var contactInfo = record[0].work_phone;
        				var customerType = record[0].customer_type;
        				var nmAccountType = record[0].nm_account_type;
        				if(judgeCustomer("agencyMan",flag)){
        					
        					$('#agencyMan').combogrid("setValue",id+"@"+customerName);        					
        					$("#agencyMan").combogrid("setText",customerName);  
        					$('#agencyContact').combogrid("setValue",id+"@"+customerName);
        					$('#agencyContact').combogrid("setText",customerName);        					
        					
        					//$('#agencyMan').val(customerName);
        					//$('#agencyContact').val(id+"@"+customerName);
        					$('#payWay').val(nmAccountType);
        					$('#clientType').val(customerType);
        					$('#contact').val(contact);
        					$('#contactInfo').val(contactInfo);
        				}
					}
                },
                //按上方向键移动选择行
                up:function(){
                    pressUp("agencyMan");
                    agencyMan();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("agencyMan");
                    agencyMan();
                },
				query: function(q) {
					likeSelect(q,"agencyMan");
				}
			}
		});
		//查询发货人
		$("#searchShipper").combogrid({
			panelWidth: 570,
			width:100,
			striped:true,
			pagination:true,
			showHeader:true,
			//url:"getConsignee.do",
			columns: [[
				{field:'spell_code',title:'检索码',width:100},
				{field:'consignee_name',title:'详细信息',width:445}
			]],
			onClickRow:function(){
				searchShipper();
			},
			keyHandler: {
				//按键事件
				enter:function(){
					var record = pressEnter("searchShipper");
					if(record!=null){
						var consigneeName = record[0].consignee_name;
        				var spellCode = record[0].spell_code;
        				$('#searchShipper').combogrid("setValue",spellCode);
        				$("#shipper").val(consigneeName);
					}
                },
                //按上方向键移动选择行
                up:function(){
                	pressUp("searchShipper");
                	searchShipper();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("searchShipper");
                	searchShipper();
                },
				query: function(q) {
					likeSelect(q,"searchShipper");
				}
			}
		});
		//查询通知人
		$("#searchNoticeMan").combogrid({
			panelWidth: 570,
			width:100,
			striped:true,
			pagination:true,
			showHeader:true,
			//url:"getConsignee.do",
			columns: [[
				{field:'spell_code',title:'检索码',width:100},
				{field:'consignee_name',title:'详细信息',width:445}
			]],
			onClickRow:function(){
				searchNoticeMan();
			},
			keyHandler: {
				//按键事件
				enter:function(){
					var record = pressEnter("searchNoticeMan");
					if(record!=null){
						var consigneeName = record[0].consignee_name;
        				var spellCode = record[0].spell_code;
        				$('#searchNoticeMan').combogrid("setValue",spellCode);
        				$("#noticeMan").val(consigneeName);
        				var boxMaster = $("#boxMaster").combogrid("getValue");
        				if("msc"==boxMaster||"MSC"==boxMaster){
        					$("#notifierMscCode").val(record[0].msc_code);
        				}
					}
                },
                //按上方向键移动选择行
                up:function(){
                	pressUp("searchNoticeMan");
                	searchNoticeMan();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("searchNoticeMan");
                	searchNoticeMan();
                },
				query: function(q) {
					likeSelect(q,"searchNoticeMan");
				}
			}
		});
		//查询收货人
		$("#searchConsignee").combogrid({
			panelWidth: 570,
			width:100,
			striped:true,
			pagination:true,
			showHeader:true,
			//url:"getConsignee.do",
			columns: [[
				{field:'spell_code',title:'检索码',width:100},
				{field:'consignee_name',title:'详细信息',width:445}
			]],
			onClickRow:function(){
				searchConsignee();
			},
			keyHandler: {
				//按键事件
				enter:function(){
					var record = pressEnter("searchConsignee");
					if(record!=null){
						var consigneeName = record[0].consignee_name;
        				var spellCode = record[0].spell_code;
        				$('#searchConsignee').combogrid("setValue",spellCode);
        				$("#consignee").val(consigneeName);
        				var boxMaster = $("#boxMaster").combogrid("getValue");
        				if("msc"==boxMaster||"MSC"==boxMaster){
        					$("#consigneeMscCode").val(record[0].msc_code);
        				}
					}
                },
                //按上方向键移动选择行
                up:function(){
                	pressUp("searchConsignee");
                	searchConsignee();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("searchConsignee");
                	searchConsignee();
                },
				query: function(q) {
					likeSelect(q,"searchConsignee");
				}
			}
		});
		//查询Port Of Loading
		var index=0;
		$("#portOfLoading").combogrid({
			panelWidth: 570,
			width:200,
			striped:true,
			pagination:true,
			showHeader:true,
			idField: 'id_',    
		    textField: 'harbour_name', 
			url:"consignMgr/getInlandHarbor.do",
			
			
			queryParams:{
				'keyword':'CHONGQING'
			},
			columns: [[
				{field:'harbour_name',title:'港区',width:142},
				{field:'english_name',title:'港口英文名',width:142},
				{field:'area_name',title:'港口名称',width:142},
				{field:'mileage',title:'里程',width:120}
			]],
			onLoadSuccess:function(){
				if(index==0){
					$("#portOfLoading").combogrid("grid").datagrid("selectRow",'0');
					var englishName = $("#portOfLoading").combogrid("grid").datagrid("getSelected").english_name;
					var mileage = $("#portOfLoading").combogrid("grid").datagrid("getSelected").mileage;
					var id = $("#portOfLoading").combogrid("grid").datagrid("getSelected").id_;
					$('#portOfLoading').combogrid("setValue",id+"@"+englishName);
					$('#portOfLoading').combogrid("setText",englishName);
					$("#portOfLoading").val(englishName);
					$("#portOfLoadingMilage").val(mileage);
					index = 1;
				}
			},
			onClickRow:function(){
				portOfLoading();
			},
			keyHandler: {
				//按键事件
				enter:function(){
					var record = pressEnter("portOfLoading");
					if(record!=null){
						var englishName = record[0].english_name;
        				var mileage = record[0].mileage;
        				var id =record[0].id_;
        				$('#portOfLoading').combogrid("setValue",id+"@"+englishName);
        				$('#portOfLoading').combogrid("setText",englishName);
        				$("#portOfLoading").val(englishName);
        				$("#portOfLoadingMilage").val(mileage);
					}
                },
                //按上方向键移动选择行
                up:function(){
                	pressUp("portOfLoading")
                	portOfLoading();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("portOfLoading");
                	portOfLoading();
                },
				query: function(q) {
					likeSelect(q,"portOfLoading");
				}
			}
		});
		$('#portOfLoading').next('span').find('input').blur(function(){
			checkInput("portOfLoading","Port Of Loading");
		});
		//查询江船起运港
		var index1=0;
		$("#loadHarbour").combogrid({
			panelWidth: 570,
			width:200,
			striped:true,
			pagination:true,
			showHeader:true,
			
			idField: 'id_',    
		    textField: 'harbour_name', 
			url:"consignMgr/getInlandHarbor.do",			
			queryParams:{
				'keyword':'寸滩'
			},
			columns: [[
				{field:'harbour_name',title:'港区',width:122},
				{field:'english_name',title:'港口英文名',width:142},
				{field:'area_name',title:'港口名称',width:122},
				{field:'mileage',title:'里程',width:60},
				{field:'custom_code',title:'关区代码',width:100}
			]],
			onLoadSuccess:function(){
				if(index1==0){
					$("#loadHarbour").combogrid("grid").datagrid("selectRow",'0');
					var harbourName = $("#loadHarbour").combogrid("grid").datagrid("getSelected").harbour_name;
					var customCode = $("#loadHarbour").combogrid("grid").datagrid("getSelected").custom_code;
					var id = $("#loadHarbour").combogrid("grid").datagrid("getSelected").id_;
					$('#loadHarbour').combogrid("setValue",id+"@"+harbourName);
					$('#loadHarbour').combogrid("setText",harbourName)
					$('#loadHarbour').val(harbourName);
					$('#customDistrict').val(customCode);
					index1 = 1;
				}
			},
			onClickRow:function(){
				loadHarbour();
			},
			keyHandler: {
				//按键事件
				enter:function(){
					var record = pressEnter("loadHarbour");
					if(record!=null){
						var areaName = record[0].area_name;
        				var englishName = record[0].english_name;
        				var customCode = record[0].custom_code;
        				$('#loadHarbour').combogrid("setValue",englishName);
        				$('#loadHarbour').combogrid("setValue",areaName);
        				$("#loadHarbour").val(areaName);
        				$('#customDistrict').val(customCode);
					}
                },
                //按上方向键移动选择行
                up:function(){
                	pressUp("loadHarbour");
                	loadHarbour();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("loadHarbour");
                	loadHarbour();
                },
				query: function(q) {
					likeSelect(q,"loadHarbour");
				}
			}
		});
		//查询Port Of Discharge
		$("#portOfDischarge").combogrid({
			panelWidth: 570,
			width:200,
			striped:true,
			pagination:true,
			showHeader:true,		
			idField: 'id_',    
		    textField: 'harbour_name', 		
			url:"consignMgr/getForeignHarbour.do",
			columns: [[
						{field:'habour_code',title:'港口代码',width:190},
						{field:'harbour_name',title:'港口名称',width:190},
						{field:'chinese_country',title:'港口所在国家',width:170}
					]],
			onClickRow:function(){
				portOfDischarge();
			},
			keyHandler: {
				//按键事件
				enter:function(){
					var record = pressEnter("portOfDischarge");
					if(record!=null){
						var habourCode = record[0].harbour_name;
        				var chineseCountry = record[0].chinese_country;
        				$('#portOfDischarge').combogrid("setValue",habourCode);
        				$("#portOfDischarge").val(habourCode);
        				//判断hscode是否必填
        				var boxMaster = $("#boxMaster").val();
        				boxMaster = boxMaster.toLowerCase();
        				habourCode = habourCode.toLowerCase();
        				if(("yml"==boxMaster||"pil"==boxMaster)&&"bandar abbas"==habourCode){
        					$("#hsf").css("color","#FF0000");
        				}else if("tsc"==boxMaster&&("kelang n.p.(北港)"==habourCode||"日本"==chineseCountry)){
        					$("#hsf").css("color","#FF0000");
        				}else{
        					$("#hsf").css("color","#FFFFFF");
        				}
					}
                },
                //按上方向键移动选择行
                up:function(){
                	pressUp("portOfDischarge");
                	portOfDischarge();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("portOfDischarge");
                	portOfDischarge();
                },
				query: function(q) {
					likeSelect(q,"portOfDischarge");
				}
			}
		});
		$('#portOfDischarge').next('span').find('input').blur(function(){
			checkInput("portOfDischarge","Port Of Discharge");
		});
		//查询Place Of Delivery
		$("#placeOfDelivery").combogrid({
			panelWidth:550,
			width:200,
			striped:true,
			pagination:true,
			showHeader:true,
			idField: 'id_',    
		    textField: 'harbour_name', 
			url:"consignMgr/getForeignHarbour.do",
			columns: [[
				{field:'habour_code',title:'港口代码',width:142},
				{field:'harbour_name',title:'港口英文名称',width:142},
				{field:'chinese_country',title:'港口所在国家名称',width:120},
				{field:'country_code',title:'国家代码',width:120}
			]],
			onClickRow:function(){
				placeOfDelivery();
			},
			keyHandler: {
				//按键事件
				enter:function(){
					var record = pressEnter("placeOfDelivery");
					if(record!=null){
						var countryCode = record[0].country_code;
						if(countryCode==""){
							$.messager.alert("警告","国家代码为空,请尽快备案!","warning");
						}
						var habourCode = record[0].harbour_name;
        				var countryName = record[0].chinese_country;
        				
        				$('#placeOfDelivery').combogrid("setValue",habourCode);
        			
        				$('#stopCountry').combogrid("setValue",countryCode+"@"+countryName);
        				$('#stopCountry').combogrid("setText",countryName);
        				$('#stopCountry').val(countryName);
        				$("#placeOfDelivery").val(habourCode);
        				//$("#stopCountry").combogrid("grid").datagrid("reload",{'keyword':countryName});
					}
                },
                //按上方向键移动选择行
                up:function(){
                	pressUp("placeOfDelivery");
                	placeOfDelivery();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("placeOfDelivery");
                	placeOfDelivery();
                },
				query: function(q) {
					likeSelect(q,"placeOfDelivery");
				}
			}
		});
		$('#placeOfDelivery').next('span').find('input').blur(function(){
			checkInput("placeOfDelivery","Place Of Delivery");
		});
		//查询目的地国家
		$("#stopCountry").combogrid({
			panelWidth: 570,
			width:200,
			striped:true,
			pagination:true,
			showHeader:true,
			idField: 'country_code',    
		    textField: 'country_ch_name', 
			url:"consignMgr/getCountryNames.do",
		
			columns: [[
						{field:'country_code',title:'国家代码',width:190},
						{field:'country_eng_name',title:'国家英文名称',width:190},
						{field:'country_ch_name',title:'国家中文名称',width:170}
					]],
			onClickRow:function(){
				stopCountry();
			},
			onChange : function(now, old) {
				
				$('#stopCountry').combogrid("setValue",now);
				$('#stopCountry').combogrid("setText",now.split("@")[1]);
				$('#stopCountry').val(now);
				
			},
			keyHandler: {
				//按键事件
				enter:function(){
					var record = pressEnter("stopCountry");
					if(record!=null){
						var countryEngName = record[0].country_ch_name;
						var id= record[0].country_code;
						
        				$('#stopCountry').combogrid("setValue",id+"@"+countryEngName);
        				$('#stopCountry').combogrid("setText",countryEngName);
        				$("#stopCountry").val(countryEngName);
					}
                },
                //按上方向键移动选择行
                up:function(){
                	pressUp("stopCountry");
                	stopCountry();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("stopCountry");
                	stopCountry();
                },
				query: function(q) {
					likeSelect(q,"stopCountry");
				}
			}
		});
		//查询运输条款
		$("#transportItem").combogrid({
			panelWidth: 570,
			width:200,
			striped:true,
			pagination:true,
			showHeader:true,
			idField: 'id_',    
		    textField: 'transport_item', 
			url:"consignMgr/getTransportItem.do",
			columns: [[
						{field:'spell_code',title:'条款简码',width:142},
						{field:'start_item',title:'起始条款',width:142},
						{field:'end_item',title:'终止条款',width:142},
						{field:'transport_item',title:'运输条款',width:120}
					]],
			onClickRow:function(){
				transportItem();
			},
			keyHandler: {
				//按键事件
				enter:function(){
					var record = pressEnter("transportItem");
					
					if(record!=null){
						var transportItem = record[0].transport_item;
						var id = record[0].id_;
						$('#transportItem').combogrid("setValue",id+"@"+transportItem);
        				$("#transportItem").val(transportItem);
					}
                },
                //按上方向键移动选择行
                up:function(){
                	pressUp("transportItem");
                	transportItem();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("transportItem");
                	transportItem();
                },
				query: function(q) {
					likeSelect(q,"transportItem");
				}
			}
		});
		//可否分批
		$("#partialFlag").combobox({
			width:200,
			editable:false,
			panelHeight:'auto',
			valueField:'value',
		    textField:'text',
		    data: [{value:'1',text:'是'},{value:'0',text:'否'}],
		    onLoadSuccess:function(){
		    	$('#partialFlag').combobox("setValue",'0');
		    }
		});
		//可否转船
		$("#changeShipFlag").combobox({
			width:200,
			editable:false,
			panelHeight:'auto',
			valueField:'value',
		    textField:'text',
		    data: [{value:'1',text:'是'},{value:'0',text:'否'}],
		    onLoadSuccess:function(){
		    	$('#changeShipFlag').combobox("setValue",'0');
		    }
		});
		//显示箱型箱量列表
		$("#boxList").datagrid({
			width:700,
			height:200,
			singleSelect:true,
			striped:true,
			columns:[[    
			        {field:'box_type',title:'箱型',width:80},
			        {field:'box_num',title:'箱量',width:80},
			        {field:'length',title:'长',width:50},
			        {field:'width',title:'宽',width:50},
			        {field:'height',title:'高',width:50},
			        {field:'overLeft',title:'左超',width:50},
			        {field:'overRight',title:'右超',width:50},
			        {field:'overFore',title:'前超',width:50},
			        {field:'overBack',title:'后超',width:50},
			        {field:'overLimit',title:'超限',width:50},
			        {field:'overHeight',title:'超高',width:50},
			        {field:'volume',title:'体积',width:75}
			    ]]
		});
		
		//总箱型确认的相关东西
		$("#boxListDiv").dialog({
			title:'箱型确定',
			width:600,    
		    height:500,
		    top:400,
		    modal:true,
		    closed:true
		});
		//显示系统中备案的箱型数据
		$("#boxListTab").datagrid({
			loadMsg:'数据加载中...',
			width:586,
			height:200,
			url:'consignMgr/getBoxType.do',
			singleSelect:true,
			striped:true,
			fit:false,
			columns:[[    
		        {field:'box_code',title:'箱型缩写',width:100},
		        {field:'box_type_name',title:'箱型名称',width:356},
		        {field:'box_edi_code',title:'箱型代码',width:100}
		    ]],
		    onClickRow:function(){
		    	var boxType = $("#boxListTab").datagrid("getSelected").box_code;
		    	$("#boxtype").val(boxType);
		    	if(boxType.indexOf("FR")!=-1||boxType.indexOf("OT")!=-1||boxType.indexOf("FL")!=-1){
		    		$("#table1").show();
		    	}else{
		    		$("#table1").hide();
		    		$("#length").numberbox("clear");
		    		$("#width").numberbox("clear");
		    		$("#height").numberbox("clear");
		    		$("#overLeft").numberbox("clear");
		    		$("#overRight").numberbox("clear");
		    		$("#overFore").numberbox("clear");
		    		$("#overBack").numberbox("clear");
		    		$("#overLimit").numberbox("clear");
		    		$("#overHeight").numberbox("clear");
		    		$("#volume").numberbox("clear");
		    	}
		    }
		});
		//输入箱量
		$("#boxnum").numberbox({
			width:100
		});
		//箱型确定按钮及事件
		$("#boxOk").linkbutton({
			iconCls:'icon-ok'
		});
		$("#boxOk").click(function(){
			var boxType = $("#boxtype").val();
			var boxNum = $("#boxnum").numberbox("getValue");
			var length = $("#length").numberbox("getValue");
			var width = $("#width").numberbox("getValue");
			var height = $("#height").numberbox("getValue");
			var overLeft = $("#overLeft").numberbox("getValue");
			var overRight = $("#overRight").numberbox("getValue");
			var overFore = $("#overFore").numberbox("getValue");
			var overBack = $("#overBack").numberbox("getValue");
			var overLimit = $("#overLimit").numberbox("getValue");
			var overHeight = $("#overHeight").numberbox("getValue");
			var volume = $("#volume").numberbox("getValue");
			if(boxType==''||boxType==null){
				$.messager.alert("提示","箱型不能为空!","warning");
				return;
			}
			if(boxNum==''||boxNum==null){
				$.messager.alert("提示","箱量不能为空!","warning");
				return;
			}
			var rows = $("#boxList").datagrid("getRows");
			for(var i=0;i<rows.length;i++){
				var boxtype=$("#boxList").datagrid('getData').rows[i].box_type;
				var boxnum=$("#boxList").datagrid('getData').rows[i].box_num;
				if(boxtype==boxType){
					$('#boxList').datagrid('updateRow',{index:i,
						row:{box_type:boxType,box_num:boxNum,length:length,overHeight:overHeight,
							width:width,height:height,overLeft:overLeft,overRight:overRight,
							overFore:overFore,overBack:overBack,overLimit:overLimit,volume:volume}});
					$("#boxtype").val("");
					$("#boxnum").numberbox("setValue","");
					$('#boxList').datagrid("clearSelections");
					return;
				}
			}
			$('#boxList').datagrid('appendRow',{box_type:boxType,box_num:boxNum,length:length,
				width:width,height:height,overLeft:overLeft,overRight:overRight,overHeight:overHeight,
				overFore:overFore,overBack:overBack,overLimit:overLimit,volume:volume});
			$("#boxtype").val("");
			$("#boxnum").numberbox("setValue","");
			$('#boxList').datagrid("clearSelections");
			$("#length").numberbox("clear");
    		$("#width").numberbox("clear");
    		$("#height").numberbox("clear");
    		$("#overLeft").numberbox("clear");
    		$("#overRight").numberbox("clear");
    		$("#overFore").numberbox("clear");
    		$("#overBack").numberbox("clear");
    		$("#overLimit").numberbox("clear");
    		$("#overHeight").numberbox("clear");
    		$("#volume").numberbox("clear");
		});
		//添加箱型箱量到托单的按钮及事件
		$("#boxAdd").linkbutton({
			iconCls:'icon-add'
		});
		$("#boxAdd").click(function(){
			var rows = $.extend([],$("#boxList").datagrid("getRows"));
			var boxType = "";
			var bigBox = 0;
			var smallBox = 0;
			var bigBoxH = 0;
			var bigbigBox = 0;
			var specialbox=0;
			var teu=0;
			for(var i=0;i<rows.length;i++){
				var boxtype=rows[i].box_type;
				var boxnum=rows[i].box_num;
				//删除行	
				if(boxtype.indexOf("20")!=-1){
					smallBox += Number(boxnum);
					
				}else if(boxtype.indexOf("45")!=-1){
					bigbigBox += Number(boxnum);
					
				}else if(boxtype.indexOf("40")!=-1&&boxtype.indexOf("HC")!=-1){
					bigBoxH += Number(boxnum);
					
				}else if(boxtype.indexOf("40")!=-1&&boxtype.indexOf("HC")==-1){
					bigBox += Number(boxnum);
				}
				if(boxtype.indexOf("GP")==-1 && boxtype.indexOf("HC")==-1&& boxtype.indexOf("HQ")==-1){
					
					specialbox+=Number(boxnum);
				}
				
				boxType += boxnum+"X"+boxtype+"&&";
			}
			teu=smallBox+bigbigBox*2+bigBoxH*2+bigBox*2;
			if(boxType.length>0){
				boxType = boxType.substring(0,boxType.length-2);
			}
			$("#"+id).val(boxType);
			$("#boxListDiv").dialog("close");
			if("boxType"==id){
				$("#bigBox").val(bigBox);
				$("#bigbigBox").val(bigbigBox);
				$("#bigBoxH").val(bigBoxH);
				$("#smallBox").val(smallBox);
				$("#teu").val(teu);
				$("#specialbox").val(specialbox);
			}
			//判断装箱方式处是否勾选,并自动带入箱型箱量
			if($("#loadType0").is(':checked')){//只能放厂装
				$("#loadBox0").val(boxType);
			}else if($("#loadType1").is(':checked')&&!$("#loadType0").is(':checked')){
				$("#loadBox1").val(boxType);
			}
		});
		var id="";
		//显示箱型确定界面 -------总箱型
		$('#boxType').focus(function(){
			id="boxType";
			$("#boxListDiv").dialog("open");
			autoLocation("boxListDiv","400");
		});
		//删除按钮
		$("#boxDel").linkbutton({
			iconCls:'icon-cancel'
		});
		$("#boxDel").bind("click",function(){
			var row = $("#boxList").datagrid("getSelected");
			var rowIndex = $("#boxList").datagrid("getRowIndex",row);
			$("#boxList").datagrid("deleteRow",rowIndex);
		});
		//显示增加箱号div
		$("#boxNoListDiv").dialog({
			title:"请输入箱号",
			width:400,
			height:350,
			modal:true,
			closed:true
		});
		//箱号显示表格
		$("#boxNoList").datagrid({
			width:360,
			striped:true,
			columns:[[    
			        {field:'box_no',title:'箱号',width:250},
			        {field:'box_no_type',title:'箱型',width:100}
			    ]]
		});
		//箱主
		$("#boxMaster").combogrid({
			panelWidth: 570,
			width:200,
			striped:true,
			pagination:true,
			showHeader:true,
			idField: 'id_',    
		    textField: 'cq_code', 				
			url:"consignMgr/getBoxMaster.do",
			
			columns: [[
						{field:'spell_code',title:'检索码',width:80},
						{field:'cq_code',title:'箱主代码',width:80},
						{field:'full_name',title:'箱主全称',width:160},
						{field:'remark',title:'备注',width:200}
					]],
			onClickRow:function(){
				boxMaster();
			},
			keyHandler: {
				//按键事件
				enter:function(){
					var record = pressEnter("boxMaster");
					if(record!=null){
						var cqCode = record[0].cq_code;
        				var remark = record[0].remark;
        				var id = record[0].id_;
        				$('#boxMaster').combogrid("setValue",id+"@"+cqCode);
        				$("#boxMaster").val(cqCode);
        				$("#boxMasterRemark").val(remark);
        				cqCode = cqCode.toLowerCase();
					}
                },
                //按上方向键移动选择行
                up:function(){
                	pressUp("boxMaster");
                	boxMaster();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("boxMaster");
                	boxMaster();
                },
				query: function(q) {
					likeSelect(q,"boxMaster");
				}
			}
		});
		//查询包装
		$("#goodsPackage").combogrid({
  			panelWidth: 452,
			width:125,
			striped:true,
			pagination:true,
			showHeader:true,
			idField: 'id_',    
		    textField: 'packaging',
			url:"consignMgr/getPackaging.do",
			columns: [[
				{field:'spell_code',title:'快捷代码',width:114},
				{field:'packaging',title:'包装方式',width:114},
				{field:'remark',title:'备注',width:114}
			]],
			onClickRow:function(){
				goodsPackage();
			},
			keyHandler: {
				//按键事件
				enter:function(){
					var record = pressEnter("goodsPackage");
					if(record!=null){
						var packaging = record[0].packaging;
						var id=record[0].id_;
        				$('#goodsPackage').val(packaging);
        				$('#goodsPackage').combogrid("setValue",id+"@"+packaging);
					}
                },
                //按上方向键移动选择行
                up:function(){
                	pressUp("goodsPackage");
                	goodsPackage();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("goodsPackage");
                	goodsPackage();
                },
				query: function(q) {
					likeSelect(q,"goodsPackage");
				}
			}
   		});
		//港装的坑比包装选择
		$("#harbourPackage").combogrid({
  			panelWidth: 452,
			width:125,
			striped:true,
			pagination:true,
			showHeader:true,
			url:"consignMgr/getPackaging.do",
			columns: [[
				{field:'spell_code',title:'快捷代码',width:114},
				{field:'packaging',title:'包装方式',width:114},
				{field:'remark',title:'备注',width:114}
			]],
			onClickRow:function(){
				harbourPackage();
			},
			keyHandler: {
				//按键事件
				enter:function(){
					var record = pressEnter("harbourPackage");
					if(record!=null){
						var packaging = record[0].packaging;
						var id= record[0].id_;
        				$('#harbourPackage').val(packaging);
        				$('#harbourPackage').combogrid("setValue",packaging);
					}
                },
                //按上方向键移动选择行
                up:function(){
                	pressUp("harbourPackage");
					harbourPackage();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("harbourPackage");
					harbourPackage();
                },
				query: function(q) {
					likeSelect(q,"harbourPackage");
				}
			}
   		});
		//提单类型
		$("#bolType").combobox({
			panelHeight:'auto',
			width:200,
			editable:false,			
			valueField:'bol_type_id',
			textField:'bol_type',
			url:'consignMgr/getBolType.do',
			onLoadSuccess:function(){
				$("#bolType").combobox("setValue","");
			}
		});
		//货源
		$("#supplyOfGoods").combobox({
			panelHeight:'auto',
			width:200,
			editable:false,
			url:'consignMgr/getGoodsSourceCombo.do',
			valueField:'goods_type_name_code',
			textField:'goods_type_name',
			onLoadSuccess:function(){
				$("#supplyOfGoods").combobox("setValue","");
			
			}
		});
		//校验并新增箱号
		//已保存箱型
		$("#noDiv").panel({
			width:380,
			height:150
		});
		var hasBoxType={};
		$("#boxNoOk").linkbutton({
			iconCls:'icon-ok'
		});
		$("#boxNoOk").bind("click",function(){
			var boxNoStr = $("#boxno").html();
			if(boxNoStr==""){
				boxNoStr = $("#boxno").val();
			}
			var boxNoType = $("#box_no_type").combobox("getValue");
			var num = $("#box_no_type").combobox("getText");
			num = num.substring(num.indexOf("(")+1,num.indexOf(")"));
			if(boxNoStr==''||boxNoStr==null){
				$.messager.alert("提示","箱号不能为空!","warning");
				return;
			}
			if(boxNoType==""||boxNoType==null){
				$.messager.alert("错误","请选择箱型!","watning");
				return;
			}
			var reg=new RegExp("\r\n","g");
			boxNoStr = boxNoStr.replace(reg," ");
			reg=new RegExp("\n","g");
			boxNoStr = boxNoStr.replace(reg,' ');
			var boxNos = boxNoStr.split(" ");
			var stopCountry = $("#stopCountry").combogrid("getValue");
			for(var i=0;i<boxNos.length;i++){
				var boxNo = boxNos[i];
				if(boxNo!=""){
					if(!checkBox(boxNo)){
						$.messager.alert("错误","箱号:"+boxNo+"错误!","error");
						break;
					}
					if("马里"==stopCountry&&(boxNo.indexOf("CMA")!=-1||boxNo.indexOf("CGM")!=-1)){
						$.messager.alert("警告","箱号:"+boxNo+"不能到MALI!","warning");
						break;
					}
					if(hasBoxType[boxNoType]>=num||num==0){
						$.messager.alert("错误",boxNoType+"的箱型箱号已添加到最大数量!","error");
						return;
					}
					var rows = $("#boxNoList").datagrid("getRows");
					for(var i=0;i<rows.length;i++){
						var boxno=$("#boxNoList").datagrid('getData').rows[i].box_no;
						if(boxno==boxNo){
							$.messager.alert("错误","不能添加相同的箱号:"+boxNo+"!","error");
							return;
						}
					}
					$('#boxNoList').datagrid('appendRow',{box_no:boxNo,box_no_type:boxNoType});
					if(hasBoxType[boxNoType]==undefined){
						hasBoxType[boxNoType]=1;
					}else{
						hasBoxType[boxNoType]=hasBoxType[boxNoType]+1;
					}
				}
			}
			//$("#boxno").val("");
		});
		//添加箱号到托单
		$("#boxNoAdd").linkbutton({
			iconCls:'icon-add'
		});
		$("#boxNoAdd").bind("click",function(){
			var boxNo="";
			var htype="";
			var rows = $("#boxNoList").datagrid("getRows");
			for(var i=0;i<rows.length;i++){
				var boxno=$("#boxNoList").datagrid('getData').rows[i].box_no;
				var box_no_type=$("#boxNoList").datagrid('getData').rows[i].box_no_type;
				boxNo += boxno+",";
				htype += box_no_type+",";
			}
			if(boxNo.length>0){
				boxNo = boxNo.substring(0,boxNo.length-1);
				htype = htype.substring(0,htype.length-1);
			}
			$("#boxNo").val(boxNo);
			$("#hBoxType").val(htype);
			$("#boxno").val("");
			$("#boxNoListDiv").dialog("close");
		});
		//删除已添加箱号
		$("#boxNoDel").linkbutton({
			iconCls:'icon-cancel'
		});
		$("#boxNoDel").bind("click",function(){
			var rows = $("#boxNoList").datagrid("getSelections");
			for(var i=0;i<rows.length;i++){
				var type = rows[i].box_no_type;
				hasBoxType[type]=0;
				var rowIndex = $("#boxNoList").datagrid("getRowIndex",rows[i]);
				$("#boxNoList").datagrid("deleteRow",rowIndex);
			}
		});
		var data=[];
		//指定箱型列表
		$("#box_no_type").combobox({
			panelHeight:'auto',
			width:150,
			valueField:'type',
		    textField:'num',
		    data:data
		});
		//显示箱号录入DIV
		$('#boxNo').bind('focus', function(){
			data=[];
			//根据箱型动态添加箱型
			var hasBoxType=$("#boxType").val();
			var hasBoxTypes=hasBoxType.split("&&"); 
			//添加数据到对象中去
			for(var i=0;i<hasBoxTypes.length;i++){
				if(hasBoxTypes[i]!=""){
					var num = hasBoxTypes[i].split("X")[0];
					var type = hasBoxTypes[i].split("X")[1];
					data[data.length]={type:type,num:type+"("+num+")"};
				}
			}
			$("#box_no_type").combobox("loadData",data);
			$("#boxNoListDiv").dialog("open");
			$("#boxNoListDiv").show();
			autoLocation("boxNoListDiv","400");
		});
		//是否指定用箱
		$("#specifiedBox").combobox({
			width:200,
			editable:false,
			panelHeight:'auto',
			valueField:'value',
			textField:'text',
			data:[{value:'0',text:'否'},{value:'1',text:'是'},{value:'2',text:'自备箱'}],
			onLoadSuccess:function(){
		    	$('#specifiedBox').combobox("setValue",'0');
		    },
			onChange:function(q){
				if("1"==q||"2"==q){
					$("#boxNo").show();
					$("#s6").show();
				}else{
					$("#boxNo").val("");
					$("#boxNo").hide();
					$("#s6").hide();
				}
				return;
			}
		});
		//代办保险
		var flag = 0;
		$("#insurance").combobox({
			width:200,
			panelHeight:'auto',
			editable:false,
			valueField:'value',
			textField:'text',
			data:[{value:'0',text:'否'},{value:'1',text:'是'}],
			onLoadSuccess:function(){
		    	$('#insurance').combobox("setValue",'0');
		    },
		    onChange:function(q){
		    	if("1"==q){
		    		$("#s7").show();
		    		$("#s8").show();
		    		$("#s9").show();
		    		$("#tr11").show();
		    		$("#bxmc").show();
		    		$("#bxje").show();
		    		$("#bxbl").show();
		    		$("#bz").show();
		    		if(flag==0){
		    			flag=1;
		    			$("#bxje").numberbox({
		    				precision:2
		    			});
		    			$("#bxbl").numberbox({
		    				precision:4
		    			});
		    		}
		    	}else{
		    		$("#s7").hide();
		    		$("#s8").hide();
		    		$("#s9").hide();
		    		$("#tr11").hide();
		    		$("#bxmc").hide();
		    		$("#bxje").hide();
		    		$("#bxbl").hide();
		    		$("#bz").hide();
		    		$("#bxmc").val("");
		    		$("#bxje").val("");
		    		$("#bxbl").val("");
		    		$("#bz").val("");
		    	}
		    }
		});
		//报关行
		var index2=0;
		$("#gateUnit").combogrid({
			panelWidth: 570,
			width:200,
			striped:true,
			pagination:true,
			showHeader:true,
			idField: 'id_',    
		    textField: 'gate_name',
			url:"consignMgr/getGateUnit.do",
			columns: [[
				{field:'id_',title:'报关行ID',hidden:true},
				{field:'spell_code',title:'检索码',width:90},
				{field:'gate_name',title:'报关行名称',width:190},
				{field:'remark',title:'备注',width:270}
			]],
			onClickRow:function(){
				gateUnit();
			},
			keyHandler: {
				//按键事件
				enter:function(){
					var record = pressEnter("gateUnit");
					if(record!=null){
						var id = record[0].id_;
        				var gateName = record[0].gate_name;
        				$('#gateUnit').combogrid("setValue",id+"@"+gateName);
        				$('#gateUnit').val(id);
					}
                },
                //按上方向键移动选择行
                up:function(){
                	pressUp("gateUnit");
                	gateUnit();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("gateUnit");
                	gateUnit();
                },
				query: function(q) {
					likeSelect(q,"gateUnit");
				}
			}
		});
		//报关方式
		$("#gateType").combobox({
			width:200,
			panelHeight:'auto',
			editable:false,
			valueField:'customs_clearance_way',
			textField:'customs_clearance_way',
			url:'consignMgr/getCustomsClearance.do',
		});
		
		//报关票数
		$("#gateNum").numberbox({
			width:200
		});
		//商检票数
		$("#sjNum").numberbox({
			width:200
		});
		//是否安排拖车
		$("#isTrailer").change(function(){
			if("2"==this.value){
	    		$("#trailerInfo").show();
	    	}else{
	    		$("#trailerInfo").hide();
	    		$("#trailerTr").hide();
	    		var rows = $("#trailerInfoTab").datagrid("getRows");
	    		for(var i=0;i<rows.length;i++){
					var rowIndex = $("#trailerInfoTab").datagrid("getRowIndex",rows[i]);
					$("#trailerInfoTab").datagrid("deleteRow",rowIndex);
				}
	    	}
		});
		$("#freeDay").numberbox({
			width:40
		});
		//2B的装箱方式选择
		$("#loadType0").click(function(){
			if($(this).is(':checked')){
				$("#loadBox0").show();
				$("#cz").show();
				$("#loadBox0").val($("#boxType").val());
				calculateBox(document.getElementById("loadBox1"));
			}else{
				$("#loadBox0").hide();
				$("#cz").hide();
				$("#loadBox0").val("");
				if($("#loadType1").is(':checked')){
					$("#loadBox1").val($("#boxType").val());
				}
			}
		});
		$("#loadType1").click(function(){
			if($(this).is(':checked')){
				$("#loadBox1").show();
				$("#loadBox1").val($("#boxType").val());
				$("#harbourPkgs").val($("#goodsPkgs").val());
				$("#harbourKg").val($("#goodsWeight").val());
				$("#harbourVolume").val($("#goodsMeasurment").val());
				$("#harbourPackage").val($("#goodsPackage").val());
				$("#harbourPackage").combogrid("setValue",$("#goodsPackage").val());
				$("#tr3").show();
				$("#tr10").show();
				$("#gz").show();
				$("#lbrf").show();
				$("#loadBoxRemark").show();
				calculateBox(document.getElementById("loadBox0"));
			}else{
				$("#loadBox1").hide();
				$("#loadBox1").val("");
				$("#tr3").hide();
				$("#tr10").hide();
				$("#gz").hide();
				$("#lbrf").hide();
				$("#loadBoxRemark").hide();
				if($("#loadType0").is(':checked')){
					$("#loadBox0").val($("#boxType").val());
				}
			}
		});
		//境内货源地
		$("#goodsSource").combogrid({
			panelWidth: 570,
			width:200,
			striped:true,
			pagination:true,
			showHeader:true,
			idField:'id_',    
		    textField:'source_code', 		
			url:"consignMgr/getGoodsSource.do",		
			
			columns: [[
				{field:'source_code',title:'货源地代码',width:190},
				{field:'source_place',title:'货源地名称',width:190},
				{field:'spell_code',title:'检索码',width:190}
			]],
			onClickRow:function(){
				goodsSource();
			},
			keyHandler: {
				//按键事件
				enter:function(){
					var record = pressEnter("goodsSource");
					if(record!=null){
						var sourceCode = record[0].source_place;
        				var sourcePlace = record[0].source_place;
        				var id  = record[0].id_;
        				$('#goodsSource').combogrid("setValue",id+"@"+sourcePlace);
        				$('#goodsSource').combogrid("setText",sourcePlace);
        				$('#goodsSource').val(sourcePlace);
					}
                },
                //按上方向键移动选择行
                up:function(){
                	pressUp("goodsSource");
                	goodsSource();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("goodsSource");
                	goodsSource();
                },
				query: function(q) {
					likeSelect(q,"goodsSource");
				}
			}
		});
		//是否木质包装
		$("#woodenPacking").combobox({
			width:100,
			panelHeight:'auto',
			editable:false,
			valueField:'value',
			textField:'text',
			data:[{value:'0',text:'否'},{value:'1',text:'是'}],
			onLoadSuccess:function(){
		    	$('#woodenPacking').combobox("setValue",'0');
		    },
		    onChange:function(q){
		    	if("1"==q){
		    		$("#span1").show();
		    	}else{
		    		$("#span1").hide();
		    		$("#hasIPPC").attr("checked",false);
		    	}
		    }
		});
		
		$("#emptyweightbox").combobox({
			width:100,
			panelHeight:'auto',
			editable:false,
			valueField:'value',
			textField:'text',
			data:[{value:'0',text:'空箱'},{value:'1',text:'重箱'}],
			onLoadSuccess:function(){
		    	$('#emptyweightbox').combobox("setValue",'1');
		    }
		  
		});
		var flagc=0;
		//危险品
		$("#dangerousName").combogrid({
			panelWidth: 570,
			width:153,
			striped:true,
			pagination:true,
			showHeader:true,
			idField:'id_',    
		    textField:'dangerous_name', 	
			url:"consignMgr/getDangerous.do",
			columns: [[
				{field:'dangerous_name',title:'危险品名',width:114},
				{field:'dangerous_type',title:'危险品种类',width:114},
				{field:'main_level',title:'危险品等级',width:114},
				{field:'internal_code',title:'国内代码',width:114},
				{field:'international_code',title:'国际代码',width:114}
			]],
			onLoadSuccess:function(){
				var rows = $("#dangerousName").combogrid("grid").datagrid("getRows");
				if(rows.length>0){
					$("#dangerousType").val(rows[0].dangerous_type);
					$("#dangerousLevel").val(rows[0].main_level);
					$("#internalCode").val(rows[0].internal_code);
					$("#internationalCode").val(rows[0].international_code);
				}
			},
			onClickRow:function(){
				dangerousName();
			},
			keyHandler: {
				//按键事件
				enter:function(){
					var record = pressEnter("dangerousName");
					if(record!=null){
						var dangerousName = record[0].dangerous_name;
	 					var mainLevel = record[0].main_level;
	 					var dangerousType = record[0].dangerous_type;
	 					var internalCode = record[0].internal_code;
	 					var internationalCode = record[0].international_code;
	 					$('#dangerousName').val(dangerousName);
	 					$("#dangerousType").val(dangerousType);
	 					$("#dangerousLevel").val(mainLevel);
	 					$("#internalCode").val(internalCode);
	 					$("#internationalCode").val(internationalCode);
	 					$('#dangerousName').combogrid("setValue",dangerousName);
					}
                },
                //按上方向键移动选择行
                up:function(){
                	pressUp("dangerousName");
                	dangerousName();
                },
              	//按下方向键移动选择行
                down:function(){
                	pressDown("dangerousName");
                	dangerousName();
                },
				query: function(q) {
					likeSelect(q,"dangerousName");
				}
			}
		});
		$("#goodsType").combobox({
			width:200,
			panelHeight:'auto',
			editable:false,
			valueField:'goods_type_name',
			textField:'goods_type_name',
			url:'consignMgr/getGoodsTypeName.do',
			onLoadSuccess:function(){
		    	$('#goodsType').combobox("setValue",'普通货物');
		    },
		    onChange:function(){
		    	var value = $('#goodsType').combobox("getValue");
				if("冷藏品"==value){
					$("#s2").show();
					$("#div2").show();
					$("#tr8").hide();
	    			$("#tr9").show();
	    			$("#s3").hide();
	    			$("#div3").hide();
	    			$("#s5").hide();
	    			$("#div7").hide();
					if(flagc==0&&flagcd==0){
						$("#coldRem").numberbox({
		    				width:200
		    			});
						flagc==1
					}else{
		    			//删除数据
		    			$('#dangerousName').combogrid('clear');
						$("#dangerousType").val('');
						$("#dangerousLevel").val('');
						$("#internalCode").val('');
						$("#internationalCode").val('');
					}
				}else if("危险品"==value){
					$("#tr8").show();
					$("#tr9").show();
					$("#s3").show();
					$("#div3").show();
					$("#s2").hide();
					$("#div2").hide();
					$("#s5").show();
	    			$("#div7").show();
	    			$("#s2").hide();
	    			$("#div2").hide();
	    			//删除数据
					$("#coldRem").numberbox('clear');
				}else if("危险冷藏品"==value){
					$("#tr8").show();
					$("#tr9").show();
					$("#s2").show();
					$("#s3").show();
					$("#div2").show();
					$("#div3").show();
					$("#s5").show();
	    			$("#div7").show();
					if(flagcd==0){
						if(flagc==0){
							$("#coldRem").numberbox({
			    				width:200
			    			});
						}
		    			flagcd=1;
					}
				}else{
					$("#tr8").hide();
					$("#tr9").hide();
					$("#s2").hide();
					$("#s3").hide();
					$("#div2").hide();
					$("#div3").hide();
					//删除数据
					if(flagc!=0&&flagcd!=0){
						$("#coldRem").numberbox('clear');
					}
	    			$('#dangerousName').combogrid('clear');
					$("#dangerousType").val('');
					$("#dangerousLevel").val('');
					$("#internalCode").val('');
					$("#internationalCode").val('');
				} 
		    }
		});
		//价格来源
		$("#priceSource").combobox({
			width:200,
			panelHeight:'auto',
			editable:false,
			valueField:'value',
			textField:'text',
			data:[{value:'1',text:'自拿价'},{value:'0',text:'销售拿价'},{value:'2',text:'市场报价'}],
			onLoadSuccess:function(){
		    	$('#priceSource').combobox("setValue",'1');
		    },
		    onChange:function(q){
		    	if("2"==q){
		    		$("#enquiryNo").attr("disabled",false);
		    	}else{
		    		$("#enquiryNo").val("");
		    		$("#enquiryNo").attr("disabled",true);
		    	}
		    }
		});
		//付费方式
		$("#carriageType").combobox({
			width:200,
			panelHeight:'auto',
			editable:false,
			valueField:'value',
			textField:'text',
			data:[{value:"",text:"--请选择运费条款--"},{value:'FREIGHT COLLECT',text:'FREIGHT COLLECT'},{value:'FREIGHT PREPAID',text:'FREIGHT PREPAID'},
			      {value:'FREIGHT COLLECT AT',text:'FREIGHT COLLECT AT'},{value:'FREIGHT PREPAID AT',text:'FREIGHT PREPAID AT'}],
			onLoadSuccess:function(){
				$("#carriageType").combobox("setValue","");
			},
		    onChange:function(q){
		    	if(q=="FREIGHT COLLECT AT"||q=="FREIGHT PREPAID AT"){
		    		$("#div4").show();
		    		$("#s4").show();
		    	}else{
		    		$("#div4").hide();
		    		$("#s4").hide();
		    		$("#thirdPlace").val("");
		    	}
		    }
		});
		//获取登录用户ID
		//getUserId();
		//获取托单录入开始时间
		getNowTime("startInputTime");
		$("#goback").linkbutton({
			iconCls:'icon-back'
		});
        $("#goback").bind("click",function(){
        	history.go(-1);
		});
		//提交保存数据
		$("#save").linkbutton({
			iconCls:'icon-save'
		});
		
		var subIndex=0;
		$("#save").bind("click",function(){
			//获取托单录入结束时间
			getNowTime("endInputTime");
			if(checkSave()){
				if(subIndex!=0){
					$.messager.alert("警告","网络连接错误","warning");
					return;
				}
				//组装拖车信息
				var rows = $("#trailerInfoTab").datagrid("getRows");
				var trailerType="";
 				var trailerAddress="";
				var trailerRemarks="";
				var returnBoxAddress="";
				var trailerDate="";
				var trailerPrice="";
				var trailerContact="";
				var trailerContactInfo="";
				var devanningType="";
				for(var i=0;i<rows.length;i++){
					var row=rows[i];
					if("目的港拖车"==row.trailer_type){
						trailerType+="1!@";
					}else{
						trailerType+="0!@";
					}
					if("装箱"==row.devanning_type){
						devanningType+="1!@";
					}else{
						devanningType+="0!@";
					}
					trailerAddress+=row.trailer_address+"!@";
					trailerRemarks+=row.trailer_remarks+"!@";
					trailerDate+=row.trailer_date+"!@";
					trailerPrice+=row.trailer_price+"!@";
					trailerContact+=row.trailer_contact+"!@";
					trailerContactInfo+=row.trailer_contact_info+"!@";
					returnBoxAddress+=row.return_box_address+"!@";
				}
				$("#trailerType").val(trailerType);
				$("#devanningType").val(devanningType);
				$("#trailerAddress").val(trailerAddress);
				$("#trailerRemarks").val(trailerRemarks);
				$("#returnBoxAddress").val(returnBoxAddress);
				$("#trailerDate").val(trailerDate);
				$("#trailerPrice").val(trailerPrice);
				$("#trailerContact").val(trailerContact);
				$("#trailerContactInfo").val(trailerContactInfo);
				var rows = $("#boxList").datagrid("getRows");
				var aa = "";
				for(var i = 0;i<rows.length;i++){
					var boxType = rows[i].box_type;
					var boxNum= rows[i].box_num;
					var length = rows[i].length;
					var width = rows[i].width;
					var height = rows[i].height;
					var overLeft = rows[i].over_left;
					var overRight = rows[i].over_right;
					var overFore = rows[i].over_fore;
					var overBack = rows[i].over_back;
					var overLimt = rows[i].over_limt;
					var overHeight = rows[i].overHeight;
					var volume = rows[i].volume;
					aa += boxType+"!"+boxNum+","+length+","+width+","+height+","+overLeft+","+overRight+","+overFore+","+overBack+","+overLimt+","+overHeight+","+volume+";"
				}
				$("#aa").val(aa);
				subIndex=1;
				$.ajax({
	                type: "POST",
 	                url:"consignMgr/consignAdd.do",
	                data:$('#form1').serialize(),
	                async: false,
	                error: function(request) {
	                	subIndex=0;
	                    alert("Connection error");
	                },
	                success: function(data) {
	                   if(data.indexOf("SUCCESS")!=-1){
	                	  $.messager.alert("提示","保存成功!","info");
	                	  setTimeout(function(){ $("#form1").attr("action",'<%=basePath%>'+"consignMgr/consignWEBill");
 		                  $("#form1").submit();},800);
	                   }else{
	                	   subIndex=0;
	                	   $.messager.alert("错误",data,"error");
	                   }
	                }
	            });
			}
		});
		//重置表单
		$("#reset").linkbutton({
			iconCls:'icon-reset'
		});
		$("#reset").bind("click",function(){
			$('#form1')[0].reset();
			//获取登录用户ID
			//getUserId();
			//获取托单录入开始时间
			getNowTime("startInputTime");
			//设置默认数据
			$("#partialFlag").combobox("setValue","0");
			$("#gateType").combobox("setValue","0");
			$("#isTrailer").combobox("setValue","0");
			$("#woodenPacking").combobox("setValue","0");
			$("#specifiedBox").combobox("setValue","0");
			$("#goodsType").combobox("setValue","普通货物");
			$("#priceSource").combobox("setValue","自拿价");
			$("#carriageType").combobox("setValue","FREIGHT COLLECT");
			$("#partialFlag").val("0");
			$("#gateType").val("0");
			$("#isTrailer").val("0");
			$("#woodenPacking").val("0");
			$("#specifiedBox").val("0");
			$("#goodsType").val("普通货物");
			$("#priceSource").val("自拿价");
			$("#carriageType").val("FREIGHT COLLECT");
		});
	});
	//提交验证
	function checkSave(){
		var businessType = parent.document.getElementById('tradeType').value;
		//var businessType = $("#tradeType").val();
	    if(isBlank(businessType,"业务类别","tradeType"))
	    {
	    	return false;
	    }
		//判断销售人员
		var salesManName = $("#salesManName").val();
		if(isBlank(salesManName,"销售人员","salesManName")){
			return false;
		}
		//判断第二销售人员
		var isTaoyue = $("#isTaoyue");
		if(isTaoyue.prop("checked")){
			var secondSalesMan = $("#secondSalesMan").val();
			if(isBlank(secondSalesMan,"第二销售人员","secondSalesMan")){
				return false;
			}
		}
		//判断托运人
		var agencyMan = $("#agencyMan").val();
		if(isBlank(agencyMan,"托运人","agencyMan")){
			return false;
		}
		//判断货主
		var agencyContact = $("#agencyContact").val();
		if(isBlank(agencyContact,"货主","agencyContact")){
			return false;
		}
		//判断江船起运港
		var loadHarbour = $("#loadHarbour").val();
		if(isBlank(loadHarbour,"江船起运港区","loadHarbour")){
			return false;
		}
		//判断发货人
		var shipper = $("#shipper").val();
		if(isBlank(shipper,"发货人","shipper")){
			return false;
		}
		if(!checkInput("shipper","发货人")){
			return false;
		}
		//判断收货人
		var consignee = $("#consignee").val();
		if(isBlank(consignee,"收货人","consignee")){
			return false;
		}
		if(!checkInput("consignee","收货人")){
			return false;
		}
		//判断通知人
		var noticeMan = $("#noticeMan").val();
		if(isBlank(noticeMan,"通知人","noticeMan")){
			return false;
		}
		if(!checkInput("noticeMan","收通知人")){
			return false;
		}
		//判断货物描述
		var goodsEnglishName = $("#goodsEnglishName").val();
		if(isBlank(goodsEnglishName,"货物描述","goodsEnglishName")){
			return false;
		}
		if(!checkInput("goodsEnglishName","货物描述")){
			return false;
		}
		//判断唛头
		var goodsSign = $("#goodsSign").val();
		if(isBlank(goodsSign,"唛头","goodsSign")){
			return false;
		}
		if(!checkInput("goodsSign","唛头")){
			return false;
		}
		//判断Port Of Loading
		var portOfLoading = $("#portOfLoading").val();
		if(isBlank(portOfLoading,"Port Of Loading","portOfLoading")){
			return false;
		}
		if(!checkInput("portOfLoading","Port Of Loading")){
			return false;
		}
		//判断Port Of Discharge
		var portOfDischarge = $("#portOfDischarge").val();
		if(isBlank(portOfDischarge,"Port Of Discharge","portOfDischarge")){
			return false;
		}
		if(!checkInput("portOfDischarge","Port Of Discharge")){
			return false;
		}
		//判断Place Of Delivery
		var placeOfDelivery = $("#placeOfDelivery").val();
		if(isBlank(placeOfDelivery,"Place Of Delivery","placeOfDelivery")){
			return false;
		}
		if(!checkInput("placeOfDelivery","Port Of placeOfDelivery")){
			return false;
		}
		//判断目的地国家
		var stopCountry = $("#stopCountry").val();
		if(isBlank(stopCountry,"目的地国家","stopCountry")){
			return false;
		}
		//判断境内货源地
		var goodsSource = $("#goodsSource").val();
		if(isBlank(goodsSource,"境内货源地 ","goodsSource")){
			return false;
		}
		var subsupplier = $("#subsupplier").val();
		if(isBlank(subsupplier,"分供方 ","subsupplier")){
			return false;
		}
		//根据船公司判断各种TMD必填项
		var boxMaster=($("#boxMaster").val()).toLowerCase();
		
		var placeOfDelivery = $("#placeOfDelivery").val();
		//判断HSCODE是否为空
		var placeOfDelivery = $("#placeOfDelivery").val();
		placeOfDelivery = placeOfDelivery.toLowerCase();
		//判断运输条款
		var transportItem = $("#transportItem").val();
		if(isBlank(transportItem,"运输条款","transportItem")){
			return false;
		}
		//判断箱型
		var boxType = $("#boxType").val();
		if(isBlank(boxType,"箱型","boxType")){
			return false;
		}
		//判断预计江船装船时间
 		var loadDate = $("#loadDate").val();
// 		if(isBlank(loadDate,"预计江船装船时间","loadDate")){
// 			return false;
// 		}
		//判断预计放箱时间时间
 		var putBoxDate = $("#putBoxDate").val();
// 		if(isBlank(putBoxDate,"预计放箱时间时间","putBoxDate")){
// 			return false;
// 		}
		//判断预计提箱时间
		var pickBoxDate = $("#pickBoxDate").val();
// 		if(isBlank(pickBoxDate,"预计提箱时间","pickBoxDate")){
// 			return false;
// 		}
		//判断中文品名
		var goodsChineseName = $("#goodsChineseName").val();
		if(isBlank(goodsChineseName,"中文品名","goodsChineseName")){
			return false;
		}
		//判断货物件数
		var goodsPkgs = $("#goodsPkgs").val();
		if(isBlank(goodsPkgs,"货物件数","goodsPkgs")){
			return false;
		}
		//判断包装
		var goodsPackage = $("#goodsPackage").val();
		if(isBlank(goodsPackage,"包装及标志","goodsPackage")){
			return false;
		}
		//判断货物毛重
		var goodsWeight = $("#goodsWeight").val();
		if(isBlank(goodsWeight,"货物毛重","goodsWeight")){
			return false;
		}
		//判断体积
		var goodsMeasurment = $("#goodsMeasurment").val();
		if(isBlank(goodsMeasurment,"体积","goodsMeasurment")){
			return false;
		}
		//判断箱主
		var boxMaster = $("#boxMaster").val();
		if(isBlank(boxMaster,"箱主","boxMaster")){
			return false;
		}
		//alert(boxMaster);
		if(boxMaster=='PIL'){
			var hsCode = $("#hsCode").val();
			if(isBlank(hsCode,"箱主为太平时HS CODE","hsCode")){
				return false;
			}
		}
		//if(boxMaster)
		//根据货物种类判断
		var goodsType = $("#goodsType").combobox("getValue");
		if(isBlank(goodsType,"货物种类","goodsType")){
			return false;
		}
		//判断冷藏温度
		if("冷藏品"==goodsType||"危险冷藏品"==goodsType){
			var coldRem = $("#coldRem").numberbox("getValue");
			if(isBlank(coldRem,"冷藏温度","coldRem")){
				return false;
			}
		}
		//判断危险品信息
		if("危险品"==goodsType||"危险冷藏品"==goodsType){
			var dangerousName = $("#dangerousName").val();
			if(isBlank(dangerousName,"危险品名","dangerousName")){
				return false;
			}
		}
		//判断船公司订舱价格
		var priceAmount = $("#priceAmount").val();
		if(isBlank(priceAmount,"船公司订舱价格","priceAmount")){
			return false;
		}
		//判断价格开始时间
		var priceStartDate = $("#priceStartDate").val();
		if(isBlank(priceStartDate,"价格开始时间","priceStartDate")){
			return false;
		}
		//判断价格停止时间
		var priceEndDate = $("#priceEndDate").val();
		if(isBlank(priceEndDate,"价格停止时间","priceEndDate")){
			return false;
		}
		//根据付费方式
		var carriageType = $("#carriageType").combobox("getValue");
		if(isBlank(carriageType, "运费方式", "carriageType")){
			return false;
		}
		if("&nbsp;"==carriageType){
			isBlank("", "运费方式", "carriageType");
			return;
		}
		if("FREIGHT COLLECT AT"==carriageType||"FREIGHT PREPAID AT"==carriageType){
			var thirdPlace = $("#thirdPlace").val();
			if(isBlank(thirdPlace,"第三地名称","thirdPlace")){
				return false;
			}
		}
		//判断报关方式
		var gateType = $("#gateType").combobox("getValue");
		if(isBlank(gateType,"报关方式","gateType")){
			return false;
		}
		//判断报关行
		var gateUnit = $("#gateUnit").combobox("getValue");
		if(isBlank(gateUnit,"报关行","gateUnit")){
			return false;
		}
		//判断申报地海关
		var customs = $("#customDistrict").val();
		if(isBlank(customs,"申报地海关","customDistrict")){
			return false;
		}
		//判断是否选择装箱方式
		if(!$("#loadType0").is(':checked')&&!$("#loadType1").is(':checked')){
			$.messager.alert("提示","请选择装箱方式","info",function(){
				$('#loadType0').focus();
				$('#loadType0').css("border","1px red solid");
				$('#loadType0').next('span').find('input').focus();
				$("#loadType0").next('span').css("border","1px red solid");
				$('#loadType1').focus();
				$('#loadType1').css("border","1px red solid");
				$('#loadType1').next('span').find('input').focus();
				$("#loadType1").next('span').css("border","1px red solid");
			});
			return false;
		}
		//判断装箱方式箱型箱量与总箱型箱量
		if(!checkBoxType()){
			return false;
		}
		//判断货物是不是已经超重了
		var bigBox = $("#bigBox").val();
		var smallBox = $("#smallBox").val();
		var bigBoxH = $("#bigBoxH").val();
		var bigbigBox = $("#bigbigBox").val();
		var goodsWeight = $("#goodsWeight").val();
		if(((Number(bigBox)+Number(smallBox)+Number(bigBoxH)+Number(bigbigBox))*28000)<Number(goodsWeight)){
			$.messager.alert("警告","货物超重,不能录入!","warning");
			return false;
		}
		return true;
	}
	//判断是否为空
	function isBlank(str,message,id){
		if($('#'+id).is(":hidden")) return false;
		if(str==''||str==null||str=="undefined"||str=="-1"){
	
			$.messager.alert("提示",message+"不能为空!","info",function(){
				$('#'+id).focus();
				$('#'+id).css("border","1px red solid");
				$('#'+id).next('span').find('input').focus();
				$("#"+id).next('span').css("border","1px red solid");
			});
			return true;
		}else{
			$('#'+id).css("border","1px #95B8E7 solid");
			$("#"+id).next().css("border","1px #95B8E7 solid");
		}
		return false;
	}
	//判断是否为空
	function isBlan(str){
		if(str==''||str==null){
			return true;
		}
		return false;
	}

	//获取当前时间
	function getNowTime(id){
		$.ajax({
			type:"POST",
			url:"consignMgr/getCurrentTime.do",
			dataType:"json",
			success:function(data){
				$.each(data,function(key,value){
					$("#"+id).val(value);
				});
			}
		});
	}
	//combogrid的各种按键选择事件如下
	//第一销售人员
	function salesManName() {
		var department = $('#salesManName').combogrid("grid").datagrid("getSelected").department;//获取部门
		var name = $('#salesManName').combogrid("grid").datagrid("getSelected").name_;//获取销售人
		var id_ = $('#salesManName').combogrid("grid").datagrid("getSelected").id_;//获取销售人ID
		var departmentid = $('#salesManName').combogrid("grid").datagrid("getSelected").departmentid;//获取部门ID
		var companyName = $('#salesManName').combogrid("grid").datagrid("getSelected").company_name;//获取所属公司
		var companyCode = $('#salesManName').combogrid("grid").datagrid("getSelected").company_code;//获取公司ID
		$("#salesManName").combogrid("setValue",id_+"@"+name);
		
		$("#salesManName").combogrid("setText",name);
		var X=departmentid+"@"+department;
		$("#salesManDep").val(X);
		$("#salesManDepShow").val(department);
		$("#salesManAgent").val(companyCode+"@"+companyName);
		$("#salesManAgentShow").val(companyName);
		$("#salesManName").val(name);
	}
	//第二销售人员
	function secondSalesMan(){
		var department = $('#secondSalesMan').combogrid("grid").datagrid("getSelected").department;//部门
		var departmentid = $('#secondSalesMan').combogrid("grid").datagrid("getSelected").departmentid;//部门ID
		var companyName = $('#secondSalesMan').combogrid("grid").datagrid("getSelected").company_name;//所属区域
		var companyCode = $('#secondSalesMan').combogrid("grid").datagrid("getSelected").company_code;//所属区域ID
		var id_ = $('#secondSalesMan').combogrid("grid").datagrid("getSelected").id_;//销售人ID
		var name = $('#secondSalesMan').combogrid("grid").datagrid("getSelected").name_;//销售人
		$("#secondSalesMan").combogrid("setValue",id_+"@"+name);
		$("#secondSalesMan").combogrid("setText",name);
		$("#secondSalesManDep").val(departmentid+"@"+department);
		$("#secondSalesManDepShow").val(department);
		$("#secondSalesAgent").val(companyCode+"@"+companyName);
		$("#secondSalesAgentShow").val(companyName);
		$("#secondSalesMan").val(name);
	}
	//托运人
	function agencyMan(){
		var flag = $("#agencyMan").combogrid("grid").datagrid("getSelected").ac;
		var customerName = $("#agencyMan").combogrid("grid").datagrid("getSelected").customer_name;
		var id = $("#agencyMan").combogrid("grid").datagrid("getSelected").id_;
		var contact = $("#agencyMan").combogrid("grid").datagrid("getSelected").work_man;
		var contactInfo = $("#agencyMan").combogrid("grid").datagrid("getSelected").work_phone;
		var customerType = $("#agencyMan").combogrid("grid").datagrid("getSelected").customer_type;
		var nmAccountType = $("#agencyMan").combogrid("grid").datagrid("getSelected").nm_account_type;
		if(judgeCustomer("agencyMan",flag)){

			$('#agencyMan').combogrid("setValue",id+"@"+customerName);        					
			$("#agencyMan").combogrid("setText",customerName);
			$('#agencyContact').combogrid("setValue",id+"@"+customerName);
			$("#agencyContact").combogrid("setText",customerName);
			//$('#agencyMan').combogrid("setValue",customerName);
			//$('#agencyContact').combogrid("setValue",customerName);
			$('#agencyMan').val(customerName);
			$('#agencyContact').val(customerName);
			$('#payWay').val(nmAccountType);
			$('#clientType').val(customerType);
			$('#contact').val(contact);
			$('#contactInfo').val(contactInfo);
		}
	}
	//货主
	function agencyContact(){
		var flag = $("#agencyContact").combogrid("grid").datagrid("getSelected").ac;
		var customerName = $("#agencyContact").combogrid("grid").datagrid("getSelected").customer_name;
		var id = $("#agencyContact").combogrid("grid").datagrid("getSelected").id_;
		if(!judgeCustomer("agencyContact",flag)){
			return;
		}
		$("#agencyContact").val(customerName);
		
		$("#agencyContact").combobox("setValue",id+"@"+customerName);
		$("#agencyContact").combobox("setText",customerName);
	}
	//箱主
	function boxMaster(){
		var cqCode = $("#boxMaster").combogrid("grid").datagrid("getSelected").cq_code;
		var remark = $("#boxMaster").combogrid("grid").datagrid("getSelected").remark;//创公司订舱注意事项
		//alert(remark)
		var id = $("#boxMaster").combogrid("grid").datagrid("getSelected").id_;
		
		$('#boxMaster').combogrid("setValue",id+"@"+cqCode);
		$('#boxMaster').combogrid("setText",cqCode);
		$("#boxMaster").val(cqCode);
		$("#boxMasterRemark").val(remark);
		cqCode = cqCode.toLowerCase();
		//判断是否为MSC
		if("msc"==cqCode){
			$("#tr2").show();
		}else{
			$("#tr2").hide();
			$('#isFeeCUC').attr("checked",false);
		}
		//判断船公司约号是否必填
		if("zim"==cqCode||"ua"==cqCode||"sjj"==cqCode||"kl"==cqCode){
			$("#yhf").css("color","#FF0000");
		}else{
			$("#yhf").css("color","#FFFFFF");
		}
	}
	//发货人
	function searchShipper(){
		var consigneeName = $("#searchShipper").combogrid("grid").datagrid("getSelected").consignee_name;
		var spellCode = $("#searchShipper").combogrid("grid").datagrid("getSelected").spell_code;
		$('#searchShipper').combogrid("setValue",spellCode);
		$("#shipper").val(consigneeName);
	}
	//收货人
	function searchConsignee(){
		var consigneeName = $("#searchConsignee").combogrid("grid").datagrid("getSelected").consignee_name;
		var spellCode = $("#searchConsignee").combogrid("grid").datagrid("getSelected").spell_code;
		var mscCode = $("#searchConsignee").combogrid("grid").datagrid("getSelected").msc_code;
		$('#searchConsignee').combogrid("setValue",spellCode);
		$("#consignee").val(consigneeName);
		var boxMaster = $("#boxMaster").combogrid("getValue");
		if("msc"==boxMaster||"MSC"==boxMaster){
			$("#consigneeMscCode").val(mscCode);
		}
	}
	//通知人
	function searchNoticeMan(){
		var consigneeName = $("#searchNoticeMan").combogrid("grid").datagrid("getSelected").consignee_name;
		var spellCode = $("#searchNoticeMan").combogrid("grid").datagrid("getSelected").spell_code;
		var mscCode = $("#searchNoticeMan").combogrid("grid").datagrid("getSelected").msc_code;
		$('#searchNoticeMan').combogrid("setValue",spellCode);
		$("#noticeMan").val(consigneeName);
		var boxMaster = $("#boxMaster").combogrid("getValue");
		if("msc"==boxMaster||"MSC"==boxMaster){
			$("#notifierMscCode").val(mscCode);
		}
	}
	//Port Of Loading
	function portOfLoading(){
		var englishName = $("#portOfLoading").combogrid("grid").datagrid("getSelected").english_name;
		var mileage = $("#portOfLoading").combogrid("grid").datagrid("getSelected").mileage;
		var id = $("#portOfLoading").combogrid("grid").datagrid("getSelected").id_;
		$('#portOfLoading').combogrid("setValue",id+"@"+englishName);
		$('#portOfLoading').combogrid("setText",englishName);
		$("#portOfLoading").val(englishName);
		$("#portOfLoadingMilage").val(mileage);
	}
	//Port Of Discharge
	function portOfDischarge(){
		var habourCode = $("#portOfDischarge").combogrid("grid").datagrid("getSelected").harbour_name;
		var chineseCountry = $("#portOfDischarge").combogrid("grid").datagrid("getSelected").chinese_country;
		var id = $("#portOfDischarge").combogrid("grid").datagrid("getSelected").id_;

		$('#portOfDischarge').combogrid("setValue",id+"@"+habourCode);
		$('#portOfDischarge').combogrid("setText",habourCode);
		$("#portOfDischarge").val(habourCode);
		//判断hscode是否必填
		var boxMaster = $("#boxMaster").val();
		boxMaster = boxMaster.toLowerCase();
		habourCode = habourCode.toLowerCase();
		if(("yml"==boxMaster||"pil"==boxMaster)&&"bandar abbas"==habourCode){
			$("#hsf").css("color","#FF0000");
		}else if("tsc"==boxMaster&&("kelang n.p.(北港)"==habourCode||"日本"==chineseCountry)){
			$("#hsf").css("color","#FF0000");
		}else{
			$("#hsf").css("color","#FFFFFF");
		}
	}
	//Place Of Delivery
	function placeOfDelivery(){
		var habourCode = $("#placeOfDelivery").combogrid("grid").datagrid("getSelected").harbour_name;
		var countryCode = $("#placeOfDelivery").combogrid("grid").datagrid("getSelected").country_code;
		var countryName = $("#placeOfDelivery").combogrid("grid").datagrid("getSelected").chinese_country;
		var id = $("#placeOfDelivery").combogrid("grid").datagrid("getSelected").id_;
		
		if(countryCode==""){
			$.messager.alert("警告","国家代码为空,请尽快备案!","warning");
		}
		$('#placeOfDelivery').combogrid("setValue",countryCode+"@"+habourCode);
		$('#placeOfDelivery').combogrid("setText",habourCode);
		
		$('#stopCountry').combogrid("setValue",countryCode+"@"+countryName);
		$('#stopCountry').combogrid("setText",countryName);
	
		$('#stopCountry').val(countryName);
		$("#placeOfDelivery").val(habourCode);
		//$("#stopCountry").combogrid("grid").datagrid("reload",{'keyword':countryName});
	}
	//江船起运港区
	function loadHarbour(){
		var id = $("#loadHarbour").combogrid("grid").datagrid("getSelected").id_;
		var harbourName = $("#loadHarbour").combogrid("grid").datagrid("getSelected").harbour_name;
		var englishName = $("#loadHarbour").combogrid("grid").datagrid("getSelected").english_name;
		var customCode = $("#loadHarbour").combogrid("grid").datagrid("getSelected").custom_code;
		//$('#loadHarbour').combogrid("setValue",englishName);
		//$('#loadHarbour').combogrid("setValue",harbourName);
		$('#loadHarbour').combogrid("setValue",id+"@"+harbourName);
		$('#loadHarbour').combogrid("setText",harbourName);
		$("#loadHarbour").val(harbourName);
		$('#customDistrict').val(customCode);
	}
	//目的地国家
	function stopCountry(){
		
		var countryEngName = $("#stopCountry").combogrid("grid").datagrid("getSelected").country_ch_name;
		var id = $("#stopCountry").combogrid("grid").datagrid("getSelected").country_code;
		$('#stopCountry').combogrid("setValue",id+"@"+countryEngName);
		$('#stopCountry').combogrid("setText",countryEngName);
		$("#stopCountry").val(countryEngName);
	}
	//境内货源地
	function goodsSource(){
		var sourceCode = $("#goodsSource").combogrid("grid").datagrid("getSelected").source_code;
		var sourcePlace = $("#goodsSource").combogrid("grid").datagrid("getSelected").source_place;
		var id = $("#goodsSource").combogrid("grid").datagrid("getSelected").id_;
		$('#goodsSource').combogrid("setValue",id+"@"+sourcePlace);
		$('#goodsSource').combogrid("setText",sourcePlace);
		$('#goodsSource').val(sourcePlace);
	}
	//分供方
	function subsupplier(){
		//var id = $("#subsupplier").combogrid("grid").datagrid("getSelected").id_;
		var code = $("#subsupplier").combogrid("grid").datagrid("getSelected").settle_department_search_code;
		var settle_company = $("#subsupplier").combogrid("grid").datagrid("getSelected").settle_company;
		//var id = $("#subsupplier").combogrid("grid").datagrid("getSelected").id_;
		$('#subsupplier').combogrid("setValue",code+"@"+settle_company);
		$('#subsupplier').combogrid("setText",settle_company);
		$('#subsupplier').val(settle_company);
	}
	//货物包装
	function goodsPackage(){
		var packaging = $("#goodsPackage").combogrid("grid").datagrid("getSelected").packaging;
		$('#goodsPackage').val(packaging);
		$('#goodsPackage').combogrid("setValue",packaging);
	}
	//港装包装
	function harbourPackage(){
		var packaging = $("#harbourPackage").combogrid("grid").datagrid("getSelected").packaging;
		$('#harbourPackage').val(packaging);
		$('#harbourPackage').combogrid("setValue",packaging);
	}
	//危险品名
	function dangerousName(){
		var row = null;
		row = $("#dangerousName").combogrid("grid").datagrid("getSelected");
		var dangerousName = row.dangerous_name;
		var mainLevel = row.main_level;
		var dangerousType = row.dangerous_type;
		var internalCode = row.internal_code;
		var internationalCode = row.international_code;
		$('#dangerousName').val(dangerousName);
		$("#dangerousType").val(dangerousType);
		$("#dangerousLevel").val(mainLevel);
		$("#internalCode").val(internalCode);
		$("#internationalCode").val(internationalCode);
		$('#dangerousName').combogrid("setValue",dangerousName);
	}
	
	//分供方（江船公司）
	$("#subsupplier").combogrid({
		panelWidth: 280,
		width:200,
		striped:true,
		pagination:true,
		showHeader:true,
		idField:'settle_department_search_code',    
	    textField:'settle_company', 		
		url:"consignMgr/getSubsupplier.do",	
		columns: [[
// 			{field:'river_boat_code',title:'江船代码',width:190},
// 			{field:'river_boat_name',title:'江船名称',width:190},
			{field:'settle_company',title:'分供方',width:190},			
// 			{field:'settle_department_search_code',title:'检索码',width:190}
		]],
		onLoadSuccess:function(){
	    	$('#subsupplier').combobox("setValue","");
	    },
		onClickRow:function(){
			subsupplier();
		},
		keyHandler: {
			//按键事件
			enter:function(){
				var record = pressEnter("subsupplier");
				if(record!=null){
 					var riverboatcode = record[0].river_boat_code;
//     				var riverboatname = record[0].river_boat_name;
    				var settle_company = record[0].settle_company;
    				$('#subsupplier').combogrid("setValue",riverboatcode+"@"+settle_company);
    				$('#subsupplier').combogrid("setText",settle_company);
    				$('#subsupplier').val(riverboatname);
				}
            },
            //按上方向键移动选择行
            up:function(){
            	pressUp("subsupplier");
            	subsupplier();
            },
          	//按下方向键移动选择行
            down:function(){
            	pressDown("subsupplier");
            	subsupplier();
            },
			query: function(q) {
				likeSelect(q,"subsupplier");
			}
		}
	});
	//运输条款
	function transportItem(){
		var transportItem = $("#transportItem").combogrid("grid").datagrid("getSelected").transport_item;
		var id = $("#transportItem").combogrid("grid").datagrid("getSelected").id_;
		$('#transportItem').combogrid("setValue",id+"@"+transportItem);
		$('#transportItem').combogrid("setText",transportItem);
		
		$("#transportItem").val(transportItem);
	}
	//报关行
	function gateUnit(){
		var id = $("#gateUnit").combogrid("grid").datagrid("getSelected").id_;
		var gateName = $("#gateUnit").combogrid("grid").datagrid("getSelected").gate_name;
		$('#gateUnit').combogrid("setValue",id+"@"+gateName);
		$('#gateUnit').combogrid("setText",gateName);
		$('#gateUnit').val(id);

	}
	//按Enter键选择唯一行
	function pressEnter(id){
		var pClosed = $("#"+id).combogrid("panel").panel("options").closed;
        if(!pClosed){
            $("#"+id).combogrid("hidePanel");
        }
        var record = $("#"+id).combogrid("grid").datagrid("getRows");
        if(record==null || record == undefined){
        	return null;
        }else {
            if(record.length==1){
            	return record;
            }else{
            	return null;
            }
        }
        if(id=="searchConsignee"){
        	var boxMaster = $("#boxMaster").combogrid("getValue");
			if("msc"==boxMaster||"MSC"==boxMaster){
				$("#consigneeMscCode").val(rowSelected.msc_code);
			}
        }
        if(id=="searchNoticeMan"){
        	var boxMaster = $("#boxMaster").combogrid("getValue");
			if("msc"==boxMaster||"MSC"==boxMaster){
				$("#notifierMscCode").val(rowSelected.msc_code);
			}
        }
	}
	//按上方向键移动选择行
	function pressUp(id){
        var pClosed = $("#"+id).combogrid("panel").panel("options").closed;
        if(pClosed){
            $("#"+id).combogrid("showPanel");
        }
        var grid = $("#"+id).combogrid("grid");
        var rowSelected = grid.datagrid("getSelected");
        if(rowSelected!=null){
            var rowIndex = grid.datagrid("getRowIndex", rowSelected);
            if(rowIndex > 0){
                rowIndex = rowIndex - 1;
                grid.datagrid("selectRow", rowIndex);
            }
        }else if(grid.datagrid("getRows").length > 0){
            grid.datagrid("selectRow", 0);
        }
        if(id=="searchConsignee"){
        	var boxMaster = $("#boxMaster").combogrid("getValue");
			if("msc"==boxMaster||"MSC"==boxMaster){
				$("#consigneeMscCode").val(rowSelected.msc_code);
			}
        }
        if(id=="searchNoticeMan"){
        	var boxMaster = $("#boxMaster").combogrid("getValue");
			if("msc"==boxMaster||"MSC"==boxMaster){
				$("#notifierMscCode").val(rowSelected.msc_code);
			}
        }
	}
	//按下方向键移动选择行
	function pressDown(id){
		var pClosed = $("#"+id).combogrid("panel").panel("options").closed;
        if(pClosed){
            $("#"+id).combogrid("showPanel");
        }
        var grid = $("#"+id).combogrid("grid");
        var rowSelected = grid.datagrid("getSelected");
        if(rowSelected != null){
            var totalRow = grid.datagrid("getRows").length;
            var rowIndex = grid.datagrid("getRowIndex", rowSelected);
            if(rowIndex < totalRow - 1){
                rowIndex = rowIndex + 1;
                grid.datagrid("selectRow", rowIndex);
            }
        }else if(grid.datagrid("getRows").length > 0){
            grid.datagrid("selectRow", 0);
        }
        if(id=="searchConsignee"){
        	var boxMaster = $("#boxMaster").combogrid("getValue");
			if("msc"==boxMaster||"MSC"==boxMaster){
				$("#consigneeMscCode").val(rowSelected.msc_code);
			}
        }
        if(id=="searchNoticeMan"){
        	var boxMaster = $("#boxMaster").combogrid("getValue");
			if("msc"==boxMaster||"MSC"==boxMaster){
				$("#notifierMscCode").val(rowSelected.msc_code);
			}
        }
	}
	//datagrid的 统一模糊查询
	function likeSelect(keyword,id){
		//动态搜索  
		$('#'+id).combogrid("grid").datagrid("reload",{'keyword':keyword,'tradeFlag':2});
		$('#'+id).combogrid("setValue",keyword);
		$('#'+id).val("");
		$('#'+id).combogrid("grid").datagrid("reload");
	}
	//光标离开时判断客户状态
	function judgeCustomer(id,flag){
		if("合同已到期"==flag){
			$.messager.alert("提示","该客户合同已到期!","info",function(){
				$('#'+id).next('span').find('input').focus();
			});
			$('#'+id).combogrid("clear");
			if(id=="agencyMan"){
				$('#agencyContact').combogrid("clear");
			}
			return false;
		}else{
			if(flag.indexOf("客户还有")!=-1){
				$.messager.alert("提示",flag,"info",function(){
					$('#'+id).next('span').find('input').focus();
				});
			}
		}
		return true;
	}
	//设定弹出框位置
	function autoLocation(id,height){
		//获取浏览器显示区域的高度   
		$(window).height();   
		//获取浏览器显示区域的宽度   
		$(window).width();   
		//获取页面的文档高度   
		$(document.body).height();   
		//获取页面的文档宽度   
		$(document.body).width();   
		//获取滚动条到顶部的垂直高度   
		$(document).scrollTop();   
		//获取滚动条到左边的垂直宽度   
		$(document).scrollLeft();
		$("#"+id).dialog("move",{top:$(document).scrollTop() + ($(window).height()-height) * 0.5});
	}
	
	//查询托单信息
	function getConsignInfo(tradeCode){
		
		var salesManName = "";
		var salesManId = "";
		var salesManName2 = "";
		var salesManId2 = "";
		$.ajax({
			type:"POST",
			url:"consignMgr/getTradeInfo.do",
			data:{tradeCode:tradeCode},
			dataType:"json",
			success:function(data){
				$.each(data[0],function(key,value){
					var index=0;
					for(var i=0;i<5;i++){
						index = key.indexOf("_");
						if(index!=-1){
							key = key.replace(key.substring(index,index+2),key.substring(index,index+2).toUpperCase());
							key = key.replace("_","");
						}
					}
					//设置文本框的值
					try {
						if(key=="boxTypeFactory"){
							$("#loadBox0").val(value);
						}else if(key=="boxTypeHarbor"){
							$("#loadBox1").val(value);
						}else if(key!="salesManName"&&key!="secondSalesMan"&&key!="salesManDep"&&key!="salesManAgent"
								&&key!="secondDep"&&key!="secondCompany"&&key!="secondSalesAgent"&&key!="boxNo"){
							if($("#"+key).attr('type')!="checkbox"){
								if("bigBoxh"==key){
									$("#bigBoxH").val(value);
								}else{
									$("#"+key).val(value);
								}
							}else{
								if(value=="Y"){
									$("#"+key).attr("checked",true);
									//设置checked选中
									if(key=="isTaoyue"){
										$("#s1").show();
										$("#tr1").show();
										$("#div1").show();
										$("#d1").show();
										$("#d2").show();
									}
								}
							}
							if(key=="boxMaster" && (value=="MSC"|| value=="msc")){
								$("#tr2").show();
							}
						}
						if(key=="salesMan"){
							$("#salesManName").val(value);
							salesManId=value;
						}else if(key=="salesManName"){
							salesManName=value;
						}
						if(key=="salesMan2"){
							$("#secondSalesMan").val(value);
							salesManId2=value;
						}else if(key=="secondSalesMan"){
							salesManName2=value;
						}
					} catch (e) {
						
					}
					try {
						likeSelect(value,key);
					} catch (e) {
						
					}
					//设置combogrid的值
					try {
						if(key=="stopHarbour"){
							$("#placeOfDelivery").combogrid("setValue",value);
							$("#placeOfDelivery").val(value);
						}else{
							$("#"+key).combogrid("setValue",value);
							$("#"+key).val(value);
						}
					} catch (e) {
						
					}
					//设置cold_rem的值
					try {
						$("#"+key).numberbox("setValue",value);
					} catch (e) {
						
					}
					//设置combobox的值
					try{
						if(key=="salesManDep"){
							$("#salesManDepShow").val(value);//销售人员部门显示
						}else if(key=="departmentId"){
							$("#salesManDep").val(value);//销售人员部门隐藏
						}else if(key=="salesManAgent"){
							$("#salesManAgentShow").val(value);//销售人员公司显示
						}else if(key=="companyCode"){
							$("#salesManAgent").val(value);//销售人员公司隐藏
						}else if(key=="secondSalesManDep"){
							$("#secondSalesManDepShow").val(value);//第二销售部门显示
						}else if(key=="secondDep"){
							$("#secondSalesManDep").val(value);//第二销售部门隐藏
						}else if(key=="secondSalesAgent"){
							$("#secondSalesAgentShow").val(value);//第二销售公司显示
						}else if(key=="secondCompany"){
							$("#secondSalesAgent").val(value);//第二销售公司隐藏
						}else if(key=="bolType"){
							if(value!=""){
								$("#"+key).combobox("setValue",value);
							}
						}else{
							$("#"+key).combobox("setValue",value);
						}
					}catch(e){
						
					}
					///ippc
					if(key=="woodenPacking"&&value=="1"){
						$("#span1").show();
					}
					//判断拖车方式
					if(key=="isTrailer"&&value=="2"){
						$("#trailerInfo").show();
						$("#trailerTr").show();
						$("#trailerShowTab").datagrid("reload",{tradeCode:tradeCode});
					}
					//显示箱号
					if(key=="specifiedBox"&&(value=="1"||value=="2")){
						$("#boxNo").show();
						$("#s6").show();
					}
					if(key=="boxLoadType"){
						if(value=="0"){
							$("#loadType0").attr("checked",true);
							$("#loadType1").attr("checked",false);
							$("#loadBox0").show();
							$("#cz").show();
							$("#tr3").hide();
							$("#tr10").hide();
							$("#gz").hide();
							$("#lbrf").hide();
							$("#loadBoxRemark").hide();
						}else if(value=="1"){
							$("#loadType0").attr("checked",false);
							$("#loadType1").attr("checked",true);
							$("#loadBox0").hide();
							$("#cz").hide();
							$("#loadBox1").show();
							$("#tr3").show();
							$("#tr10").show();
							$("#gz").show();
							$("#lbrf").show();
							$("#loadBoxRemark").show();
						}else if(value=="2"){
							$("#loadType0").attr("checked",true);
							$("#loadType1").attr("checked",true);
							$("#loadBox0").show();
							$("#cz").show();
							$("#loadBox1").show();
							$("#tr3").show();
							$("#tr10").show();
							$("#gz").show();
							$("#lbrf").show();
							$("#loadBoxRemark").show();
						}
					}
					if(key=="forwarderMan"){
						$("#forwarder_man").val(value);
					}
				});
				$("#salesManName").combogrid("setValue",salesManId);
				$("#salesManName").combogrid("setText",salesManName);
				if(""!=salesManId2){
					$("#secondSalesMan").combogrid("setValue",salesManId2);
					$("#secondSalesMan").combogrid("setText",salesManName2);
				}
			}
		});
	}
</script>
</html>